Class: Iora::Models::Image

Inherits:
Element
  • Object
show all
Defined in:
lib/iora/models/image.rb

Overview

The Image class represents an element, an element returned by the Wolfram Alpha API when image results are requested. They point to stored image files (usually GIFs, but sometimes JPEGs) giving a formatted visual representation of a single subpod.

Image#to_html will return a string containing an HTML img element suitable for direct inclusion in a webpage.

Instance Attribute Summary

Attributes inherited from Element

#element

Instance Method Summary collapse

Methods inherited from Element

#initialize, #to_xml

Methods included from Associations::HasOne

#has_one

Methods included from Associations::Helpers

#parse_element, #tag_for

Methods included from Associations::HasMany

#has_many

Methods included from Associations::HasAttribute

#has_attribute

Constructor Details

This class inherits a constructor from Iora::Models::Element

Instance Method Details

#alt_textString

Returns the alternative text describing the image.

Returns:

  • (String)

    the alternative text describing the image


20
# File 'lib/iora/models/image.rb', line 20

has_attribute :alt_text, tag: 'alt'

#heightInteger

Returns the image height, in pixels.

Returns:

  • (Integer)

    the image height, in pixels


32
# File 'lib/iora/models/image.rb', line 32

has_attribute :height, Integer

#mime_typeString

Returns the image MIME type.

Returns:

  • (String)

    the image MIME type


36
37
38
39
# File 'lib/iora/models/image.rb', line 36

def mime_type
  return unless /MSPStoreType=(?<mime_type>[a-z_\/]+)/ =~ url
  mime_type
end

#titleString

Returns the image title.

Returns:

  • (String)

    the image title


24
# File 'lib/iora/models/image.rb', line 24

has_attribute :title

#urlString

Returns the image URL.

Returns:

  • (String)

    the image URL


16
# File 'lib/iora/models/image.rb', line 16

has_attribute :url, tag: 'src'

#widthInteger

Returns the image width, in pixels.

Returns:

  • (Integer)

    the image width, in pixels


28
# File 'lib/iora/models/image.rb', line 28

has_attribute :width, Integer