Class: EOAT::Result::EveType::Row
- Inherits:
-
Object
- Object
- EOAT::Result::EveType::Row
- Defined in:
- lib/eoat/result/eve_type.rb
Overview
Key-values container. All methods generated automatically.
Instance Method Summary collapse
-
#initialize(hash) ⇒ Row
constructor
A new instance of Row.
Constructor Details
#initialize(hash) ⇒ Row
Returns a new instance of Row.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/eoat/result/eve_type.rb', line 116 def initialize(hash) hash.each do |key, value| case value when Hash if value.key? 'row' var_name = value['name'] var_value = RowSet.new(value) else var_name = key var_value = Row.new(value) end self.instance_variable_set("@#{var_name}",var_value) self.class.send( :define_method, var_name, proc { self.instance_variable_get("@#{var_name}") } ) when String, NilClass self.instance_variable_set("@#{key}", value) self.class.send( :define_method, key, proc { self.instance_variable_get("@#{key}") } ) when Array value.each do |element| self.instance_variable_set("@#{element['name']}", RowSet.new(element)) self.class.send( :define_method, element['name'], proc { self.instance_variable_get("@#{element['name']}") } ) end else raise EOAT::Exception::ParseError.new "Unable to parse the the key: #{key}, value: #{value.class}; hash: #{hash}." end end end |