Class: FlickRaw::Response
- Inherits:
-
Object
- Object
- FlickRaw::Response
- Defined in:
- lib/flickraw.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#flickr_type ⇒ Object
readonly
Returns the value of attribute flickr_type.
Class Method Summary collapse
-
.build(h, type) ⇒ Object
:nodoc:.
Instance Method Summary collapse
- #[](k) ⇒ Object
-
#initialize(h, type) ⇒ Response
constructor
:nodoc:.
- #inspect ⇒ Object
- #marshal_dump ⇒ Object
- #marshal_load(data) ⇒ Object
- #to_hash ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(h, type) ⇒ Response
:nodoc:
174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/flickraw.rb', line 174 def initialize(h, type) # :nodoc: @flickr_type, @h = type, {} methods = "class << self;" h.each {|k,v| @h[k] = case v when Hash then Response.build(v, k) when Array then v.collect {|e| Response.build(e, k)} else v end methods << "def #{k}; @h['#{k}'] end;" } eval methods << "end" end |
Instance Attribute Details
#flickr_type ⇒ Object (readonly)
Returns the value of attribute flickr_type.
173 174 175 |
# File 'lib/flickraw.rb', line 173 def flickr_type @flickr_type end |
Class Method Details
.build(h, type) ⇒ Object
:nodoc:
161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/flickraw.rb', line 161 def self.build(h, type) # :nodoc: if h.is_a? Response h elsif type =~ /s$/ and (a = h[$`]).is_a? Array ResponseList.new(h, type, a.collect {|e| Response.build(e, $`)}) elsif h.keys == ["_content"] h["_content"] else Response.new(h, type) end end |
Instance Method Details
#[](k) ⇒ Object
187 |
# File 'lib/flickraw.rb', line 187 def [](k); @h[k] end |
#inspect ⇒ Object
189 |
# File 'lib/flickraw.rb', line 189 def inspect; @h.inspect end |
#marshal_dump ⇒ Object
191 |
# File 'lib/flickraw.rb', line 191 def marshal_dump; [@h, @flickr_type] end |
#marshal_load(data) ⇒ Object
192 |
# File 'lib/flickraw.rb', line 192 def marshal_load(data); initialize(*data) end |
#to_hash ⇒ Object
190 |
# File 'lib/flickraw.rb', line 190 def to_hash; @h end |
#to_s ⇒ Object
188 |
# File 'lib/flickraw.rb', line 188 def to_s; @h["_content"] || super end |