Class: ImageInfo::Image
- Inherits:
-
Object
- Object
- ImageInfo::Image
- Defined in:
- lib/image_info/image.rb
Defined Under Namespace
Classes: NullUri
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#type ⇒ Object
Returns the value of attribute type.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(uri) ⇒ Image
constructor
A new instance of Image.
- #size ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(uri) ⇒ Image
Returns a new instance of Image.
8 9 10 11 12 13 14 15 |
# File 'lib/image_info/image.rb', line 8 def initialize(uri) @uri = ::Addressable::URI.parse(uri.to_s) @uri.scheme = 'http' unless @uri.scheme @uri.port = 80 unless @uri.port @uri.normalize! rescue ::Addressable::URI::InvalidURIError @uri = NullUri.new end |
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height.
6 7 8 |
# File 'lib/image_info/image.rb', line 6 def height @height end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/image_info/image.rb', line 6 def type @type end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
5 6 7 |
# File 'lib/image_info/image.rb', line 5 def uri @uri end |
#width ⇒ Object
Returns the value of attribute width.
6 7 8 |
# File 'lib/image_info/image.rb', line 6 def width @width end |
Instance Method Details
#size ⇒ Object
17 18 19 |
# File 'lib/image_info/image.rb', line 17 def size [width, height].compact end |
#valid? ⇒ Boolean
21 22 23 |
# File 'lib/image_info/image.rb', line 21 def valid? !!uri.host end |