Class: Pangrid::Rebus

Inherits:
Object
  • Object
show all
Defined in:
lib/pangrid/xw.rb

Overview

symbol: the symbol representing the solution in the grid

(populated by xword.encode_rebus!)

solution: the word the symbol represents display_char: optional character representation of a rebus square

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str, char = nil) ⇒ Rebus

Returns a new instance of Rebus.



15
16
17
18
19
# File 'lib/pangrid/xw.rb', line 15

def initialize(str, char = nil)
  @symbol = nil
  @solution = str
  @display_char = char || str[0]
end

Instance Attribute Details

#display_charObject

Returns the value of attribute display_char.



13
14
15
# File 'lib/pangrid/xw.rb', line 13

def display_char
  @display_char
end

#solutionObject

Returns the value of attribute solution.



13
14
15
# File 'lib/pangrid/xw.rb', line 13

def solution
  @solution
end

#symbolObject

Returns the value of attribute symbol.



13
14
15
# File 'lib/pangrid/xw.rb', line 13

def symbol
  @symbol
end

Instance Method Details

#inspectObject



25
26
27
# File 'lib/pangrid/xw.rb', line 25

def inspect
  "[#{symbol}|#{solution}]"
end

#to_charObject



21
22
23
# File 'lib/pangrid/xw.rb', line 21

def to_char
  symbol || display_char
end