Class: TheTvDb::Api::Image
Instance Attribute Summary collapse
-
#xml_node ⇒ Object
Returns the value of attribute xml_node.
Instance Method Summary collapse
- #aspect ⇒ Object
- #height ⇒ Object
-
#initialize(input_xml_node) ⇒ Image
constructor
A new instance of Image.
- #language ⇒ Object
- #network_id ⇒ Object
- #path ⇒ Object
- #pixels ⇒ Object
- #rating ⇒ Object
- #sub_type ⇒ Object
- #type ⇒ Object
- #widescreen? ⇒ Boolean
- #width ⇒ Object
Constructor Details
#initialize(input_xml_node) ⇒ Image
Returns a new instance of Image.
10 11 12 13 |
# File 'lib/the_tv_db/api/image.rb', line 10 def initialize(input_xml_node) @xml_node = input_xml_node self end |
Instance Attribute Details
#xml_node ⇒ Object
Returns the value of attribute xml_node.
8 9 10 |
# File 'lib/the_tv_db/api/image.rb', line 8 def xml_node @xml_node end |
Instance Method Details
#aspect ⇒ Object
63 64 65 66 67 68 |
# File 'lib/the_tv_db/api/image.rb', line 63 def aspect if height and width gcd = height.gcd(width) [(width / gcd), (height / gcd)] end end |
#height ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/the_tv_db/api/image.rb', line 55 def height if subtype_looks_like_dimensions? height_from_subtype elsif can_read_image_file? image_geometry[:height] end end |
#language ⇒ Object
23 24 25 |
# File 'lib/the_tv_db/api/image.rb', line 23 def language xpath('.//Language').try(:to_sym) end |
#network_id ⇒ Object
35 36 37 |
# File 'lib/the_tv_db/api/image.rb', line 35 def network_id xpath('.//id').to_i end |
#path ⇒ Object
31 32 33 |
# File 'lib/the_tv_db/api/image.rb', line 31 def path "#{TheTvDb::Api::Mirrors.all.first}/banners/#{xpath('.//BannerPath')}" end |
#pixels ⇒ Object
43 44 45 |
# File 'lib/the_tv_db/api/image.rb', line 43 def pixels (width * height).to_i rescue 0 end |
#rating ⇒ Object
15 16 17 |
# File 'lib/the_tv_db/api/image.rb', line 15 def xpath('.//Rating').try(:to_f).try(:round, 1) end |
#sub_type ⇒ Object
27 28 29 |
# File 'lib/the_tv_db/api/image.rb', line 27 def sub_type xpath('.//BannerType2').try(:to_sym) unless subtype_looks_like_dimensions? end |
#type ⇒ Object
19 20 21 |
# File 'lib/the_tv_db/api/image.rb', line 19 def type xpath('.//BannerType').try(:to_sym) end |
#widescreen? ⇒ Boolean
39 40 41 |
# File 'lib/the_tv_db/api/image.rb', line 39 def widescreen? aspect && (aspect[0].to_f / aspect[1] >= (16.to_f / 9 )) end |
#width ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/the_tv_db/api/image.rb', line 47 def width if subtype_looks_like_dimensions? width_from_subtype elsif can_read_image_file? image_geometry[:width] end end |