Class: Cards::Card
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#color ⇒ Object
Returns the value of attribute color.
- #layout ⇒ Object
-
#name ⇒ Object
Returns the value of attribute name.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #add(*cards) ⇒ Object
- #cell ⇒ Object
- #cell=(cells) ⇒ Object
- #height ⇒ Object
-
#initialize(name) ⇒ Card
constructor
A new instance of Card.
- #visit {|_self| ... } ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(name) ⇒ Card
Returns a new instance of Card.
6 7 8 9 10 |
# File 'lib/cards/card.rb', line 6 def initialize(name) @name = name @x, @y = 0, 0 @children = [] end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
3 4 5 |
# File 'lib/cards/card.rb', line 3 def children @children end |
#color ⇒ Object
Returns the value of attribute color.
3 4 5 |
# File 'lib/cards/card.rb', line 3 def color @color end |
#layout ⇒ Object
21 22 23 |
# File 'lib/cards/card.rb', line 21 def layout my_layout.layout(self) end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/cards/card.rb', line 3 def name @name end |
Instance Method Details
#add(*cards) ⇒ Object
12 13 14 |
# File 'lib/cards/card.rb', line 12 def add(*cards) @children += cards end |
#cell ⇒ Object
35 |
# File 'lib/cards/card.rb', line 35 def cell() [x, y]; end |
#cell=(cells) ⇒ Object
36 |
# File 'lib/cards/card.rb', line 36 def cell=(cells) self.x, self.y = *cells; end |
#height ⇒ Object
30 31 32 33 |
# File 'lib/cards/card.rb', line 30 def height return 1 if children.empty? my_layout.height(self) end |
#visit {|_self| ... } ⇒ Object
16 17 18 19 |
# File 'lib/cards/card.rb', line 16 def visit(&block) yield self @children.each {|c| c.visit(&block) } end |
#width ⇒ Object
25 26 27 28 |
# File 'lib/cards/card.rb', line 25 def width return 1 if children.empty? my_layout.width(self) end |