class Allure::JSONable
General jsonable object implementation
Public Instance Methods
==(other)
click to toggle source
Object comparator @param [JSONable] other @return [Booelan]
# File lib/allure_ruby_commons/model/01_jsonable.rb, line 23 def ==(other) self.class == other.class && state == other.state end
to_hash()
click to toggle source
Return object hash represantation @return [Hash]
# File lib/allure_ruby_commons/model/01_jsonable.rb, line 12 def to_hash instance_variables.each_with_object({}) do |var, map| key = camelcase(var.to_s.delete_prefix("@")) value = instance_variable_get(var) map[key] = value unless value.nil? end end
Protected Instance Methods
state()
click to toggle source
Object state @return [Array]
# File lib/allure_ruby_commons/model/01_jsonable.rb, line 31 def state instance_variables.map { |var| instance_variable_get(var) } end
Private Instance Methods
camelcase(str)
click to toggle source
Covert string to camelcase @param [String] str @return [String]
# File lib/allure_ruby_commons/model/01_jsonable.rb, line 40 def camelcase(str) str = str.gsub(/(?:_+)([a-z])/) { Regexp.last_match(1).upcase } str.gsub(/(\A|\s)([A-Z])/) { Regexp.last_match(1) + Regexp.last_match(2).downcase } end