Class: Use
- Inherits:
-
Object
- Object
- Use
- Defined in:
- lib/Olib/core/use.rb
Instance Attribute Summary collapse
-
#item ⇒ Object
Returns the value of attribute item.
Instance Method Summary collapse
- #both(&block) ⇒ Object
-
#initialize(item, &block) ⇒ Use
constructor
A new instance of Use.
- #left(&block) ⇒ Object
- #right(&block) ⇒ Object
- #run {|@item| ... } ⇒ Object
Constructor Details
#initialize(item, &block) ⇒ Use
Returns a new instance of Use.
4 5 6 7 8 |
# File 'lib/Olib/core/use.rb', line 4 def initialize(item, &block) fail Exception, "Use(#{item}) did not have a container" if item.container.nil? @item = item both(&block) if block end |
Instance Attribute Details
#item ⇒ Object
Returns the value of attribute item.
2 3 4 |
# File 'lib/Olib/core/use.rb', line 2 def item @item end |
Instance Method Details
#both(&block) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/Olib/core/use.rb', line 30 def both(&block) empty_hands @item.take self.run(&block) fill_hands end |
#left(&block) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/Olib/core/use.rb', line 15 def left(&block) empty_left_hand @item.take Char.swap if Char.right.id == @item.id self.run(&block) fill_left_hand end |
#right(&block) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/Olib/core/use.rb', line 23 def right(&block) empty_right_hand @item.take self.run(&block) fill_right_hand end |
#run {|@item| ... } ⇒ Object
10 11 12 13 |
# File 'lib/Olib/core/use.rb', line 10 def run(&block) yield @item @item.container.add(@item) unless item.gone? end |