Class: JSONable
- Inherits:
-
Object
show all
- Defined in:
- lib/bashman.rb
Instance Method Summary
collapse
Instance Method Details
#from_json!(string) ⇒ Object
57
58
59
60
61
|
# File 'lib/bashman.rb', line 57
def from_json!(string)
JSON.load(string).each do |var, val|
self.instance_variable_set(var, val)
end
end
|
#to_hash ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/bashman.rb', line 44
def to_hash
hash = {}
self.instance_variables.each do |var|
hash[var] = self.instance_variable_get(var)
end
hash
end
|
#to_json ⇒ Object
52
53
54
55
|
# File 'lib/bashman.rb', line 52
def to_json
hash = self.to_hash
hash.to_json
end
|