class JSONable
Public Instance Methods
from_json!(string)
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# File lib/bashman.rb, line 52 def to_json hash = self.to_hash hash.to_json end