Class: Pangrid::Cell
- Inherits:
-
Object
- Object
- Pangrid::Cell
- Defined in:
- lib/pangrid/xw.rb
Overview
solution = :black | :null | char | Rebus number = int borders = [:left, :right, :top, :bottom]
Instance Attribute Summary collapse
-
#borders ⇒ Object
Returns the value of attribute borders.
-
#number ⇒ Object
Returns the value of attribute number.
-
#solution ⇒ Object
Returns the value of attribute solution.
Instance Method Summary collapse
- #black? ⇒ Boolean
- #has_bar?(s) ⇒ Boolean
-
#initialize(**args) ⇒ Cell
constructor
A new instance of Cell.
- #inspect ⇒ Object
- #rebus? ⇒ Boolean
- #to_char ⇒ Object
- #to_w ⇒ Object
Constructor Details
#initialize(**args) ⇒ Cell
Returns a new instance of Cell.
36 37 38 |
# File 'lib/pangrid/xw.rb', line 36 def initialize(**args) args.each {|k,v| self.send :"#{k}=", v} end |
Instance Attribute Details
#borders ⇒ Object
Returns the value of attribute borders.
34 35 36 |
# File 'lib/pangrid/xw.rb', line 34 def borders @borders end |
#number ⇒ Object
Returns the value of attribute number.
34 35 36 |
# File 'lib/pangrid/xw.rb', line 34 def number @number end |
#solution ⇒ Object
Returns the value of attribute solution.
34 35 36 |
# File 'lib/pangrid/xw.rb', line 34 def solution @solution end |
Instance Method Details
#black? ⇒ Boolean
40 41 42 |
# File 'lib/pangrid/xw.rb', line 40 def black? solution == :black end |
#has_bar?(s) ⇒ Boolean
44 45 46 |
# File 'lib/pangrid/xw.rb', line 44 def (s) borders.include? s end |
#inspect ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/pangrid/xw.rb', line 65 def inspect case solution when :black; '#' when :null; '.' when Rebus; solution.inspect else; solution end end |
#to_char ⇒ Object
52 53 54 |
# File 'lib/pangrid/xw.rb', line 52 def to_char rebus? ? solution.to_char : solution end |
#to_w ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/pangrid/xw.rb', line 56 def to_w case solution when :black; '#' when :null; '.' when Rebus; solution.inspect else; solution end end |