Class: Tmdb::Struct
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Tmdb::Struct
- Defined in:
- lib/tmdb/struct.rb
Direct Known Subclasses
Account, Authentication, Backdrop, Certification, Change, ChangeItem, Collection, Company, Configuration, Country, Credit, Discover, Find, Genre, Image, Job, Keyword, Language, List, Media, Movie, Multi, Network, Person, Poster, Rating, Release, Review, Search, TV, Translation, Tv::Episode, Tv::Season, Video
Instance Method Summary collapse
- #analyze_value(v) ⇒ Object
-
#initialize(data = nil) ⇒ Struct
constructor
A new instance of Struct.
Constructor Details
#initialize(data = nil) ⇒ Struct
Returns a new instance of Struct.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/tmdb/struct.rb', line 4 def initialize(data=nil) @table = {} if data data.each do |k,v| @table[k.to_sym] = analyze_value(v) new_ostruct_member(k) end end end |
Instance Method Details
#analyze_value(v) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/tmdb/struct.rb', line 16 def analyze_value(v) case when v.is_a?(Hash) self.class.new(v) when v.is_a?(Array) v.map do |element| analyze_value(element) end else v end end |