Class: Writer::SymbolMatrix
- Inherits:
-
Object
- Object
- Writer::SymbolMatrix
- Defined in:
- lib/writer/symbolmatrix.rb
Instance Attribute Summary collapse
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #hash ⇒ Object
-
#initialize(source) ⇒ SymbolMatrix
constructor
A new instance of SymbolMatrix.
- #serialization(prefix = nil) ⇒ Object (also: #smas)
Constructor Details
#initialize(source) ⇒ SymbolMatrix
Returns a new instance of SymbolMatrix.
5 6 7 |
# File 'lib/writer/symbolmatrix.rb', line 5 def initialize source @source = source end |
Instance Attribute Details
#source ⇒ Object
Returns the value of attribute source.
3 4 5 |
# File 'lib/writer/symbolmatrix.rb', line 3 def source @source end |
Instance Method Details
#hash ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/writer/symbolmatrix.rb', line 23 def hash the_hash = {} @source.each do |key, value| if value.respond_to? :to the_hash[key] = value.to.hash else the_hash[key] = value end end the_hash end |
#serialization(prefix = nil) ⇒ Object Also known as: smas
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/writer/symbolmatrix.rb', line 9 def serialization prefix = nil result = "" @source.each do |key, value| unless value.is_a? Hash result += " #{prefix}#{key}:#{value}" else result += " " + Writer::SymbolMatrix.new(value).serialization("#{prefix}#{key}.") end end result[1..-1] end |