Class: Tmdb::Struct
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, Recommendation, Release, Result, 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.
3 4 5 6 7 8 9 10 11 |
# File 'lib/tmdb/struct.rb', line 3 def initialize(data=nil) @table = {} if data data.each do |k,v| self[k] = analyze_value(v) end end end |
Instance Method Details
#analyze_value(v) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/tmdb/struct.rb', line 13 def analyze_value(v) case v when Hash self.class.new(v) when Array v.map do |element| analyze_value(element) end else v end end |