Module: Coinsetter::Helper
- Defined in:
- lib/coinsetter/helper.rb
Class Method Summary collapse
- .parse_message!(string) ⇒ Object
- .parse_object!(object, klass) ⇒ Object
- .parse_objects!(string, klass) ⇒ Object
Class Method Details
.parse_message!(string) ⇒ Object
18 19 20 21 22 |
# File 'lib/coinsetter/helper.rb', line 18 def self.(string) string = "[]" if string == "" JSON.parse(string) end |
.parse_object!(object, klass) ⇒ Object
12 13 14 15 16 |
# File 'lib/coinsetter/helper.rb', line 12 def self.parse_object!(object, klass) object = JSON.parse(object) if object.is_a? String klass.new(object) end |
.parse_objects!(string, klass) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/coinsetter/helper.rb', line 3 def self.parse_objects!(string, klass) string = "{\"empty\":[]}" if string == "" objects = JSON.parse(string).first.last objects.collect do |t_json| parse_object!(t_json, klass) end end |