Class: Eve::API::Response
- Inherits:
-
Object
- Object
- Eve::API::Response
- Includes:
- Inspection, Rowsets, WrapObject
- Defined in:
- lib/eve/api/response.rb,
lib/eve/api/response/rowset.rb,
lib/eve/api/response/rowsets.rb,
lib/eve/api/response/inspection.rb,
lib/eve/api/response/wrap_object.rb
Defined Under Namespace
Modules: Inspection, Rowsets, WrapObject Classes: Rowset
Instance Attribute Summary collapse
-
#api_version ⇒ Object
readonly
Returns the value of attribute api_version.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(xml, options = {}) ⇒ Response
constructor
A new instance of Response.
- #to_hash ⇒ Object
- #to_yaml(*args) ⇒ Object
Methods included from Inspection
#inspect, #inspected_elements, #inspected_instance_variables, #inspected_name, #inspected_rowsets, #protected_instance_variables
Methods included from Rowsets
#add_rowset, #copy_attributes, #rowset_names, #rowsets, #value_for
Methods included from WrapObject
Constructor Details
#initialize(xml, options = {}) ⇒ Response
Returns a new instance of Response.
14 15 16 17 18 19 20 21 |
# File 'lib/eve/api/response.rb', line 14 def initialize(xml, = {}) @options = xml = Hpricot::XML(xml).root if xml.kind_of?(String) @xml = xml #@attributes = {} parse_xml unless [:process_xml] == false end |
Instance Attribute Details
#api_version ⇒ Object (readonly)
Returns the value of attribute api_version.
12 13 14 |
# File 'lib/eve/api/response.rb', line 12 def api_version @api_version end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
12 13 14 |
# File 'lib/eve/api/response.rb', line 12 def content @content end |
Instance Method Details
#[](key) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/eve/api/response.rb', line 41 def [](key) key = key.to_s if !key.kind_of?(String) key = key.underscore instance_variable_get("@#{key}") || raise(ArgumentError, "No attribute called '#{key}' seems to exist in #{self.inspect}") end |
#to_hash ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/eve/api/response.rb', line 23 def to_hash hash = {} (instance_variables - protected_instance_variables + (@name.blank? ? [] : ["@name"])).each do |ivar| value = instance_variable_get(ivar) value = case value when Rowset then value.to_a when Response then value.to_hash else value end hash[ivar[1..-1]] = value end hash end |
#to_yaml(*args) ⇒ Object
37 38 39 |
# File 'lib/eve/api/response.rb', line 37 def to_yaml(*args) to_hash.to_yaml(*args) end |