Class: DSON::Value::HashValue
- Inherits:
-
Object
- Object
- DSON::Value::HashValue
- Includes:
- DSON::Value
- Defined in:
- lib/DSON/value/hash_value.rb
Constant Summary collapse
- POTENTIAL_PUNCTUATION =
%w(, . ! ?)
Constants included from DSON::Value
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(value) ⇒ HashValue
constructor
A new instance of HashValue.
- #such_serialize_wow ⇒ Object
Methods included from DSON::Value
handle_next, new, remove_first_and_last_elements, remove_first_and_last_words
Constructor Details
#initialize(value) ⇒ HashValue
Returns a new instance of HashValue.
35 36 37 |
# File 'lib/DSON/value/hash_value.rb', line 35 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
33 34 35 |
# File 'lib/DSON/value/hash_value.rb', line 33 def value @value end |
Class Method Details
.parse_pair(string, acc_hash) ⇒ Object
49 50 51 52 53 |
# File 'lib/DSON/value/hash_value.rb', line 49 def self.parse_pair(string, acc_hash) results = string.scan(/"(.*)" is (.*)/) acc_hash[results[0][0]] = DSON::Value.so_parse(results[0][1]) acc_hash end |
.so_parse(options) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/DSON/value/hash_value.rb', line 9 def self.so_parse() word_array = [:word_array] parent_hash = [:parent_hash] return parent_hash if word_array.empty? if word_array[0] == 'wow' word_array.shift return parent_hash end # The next value will be a key key = word_array.shift[1..-2] # remove is word_array.shift value = DSON::Value.handle_next() parent_hash[key] = value so_parse() end |
Instance Method Details
#such_serialize_wow ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/DSON/value/hash_value.rb', line 39 def such_serialize_wow strings = value.keys.map do |key| key_str = StringValue.new(key).such_serialize_wow value_str = Value.new(value[key]).such_serialize_wow %Q(#{key_str} is #{value_str}) end 'such ' + reduce(strings, POTENTIAL_PUNCTUATION) + 'wow' end |