Class: ImageInfo::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/image_info/image.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ Image

Returns a new instance of Image.



9
10
11
# File 'lib/image_info/image.rb', line 9

def initialize(uri)
  @uri = ::URI.parse(uri.to_s)
end

Instance Attribute Details

#heightObject

Returns the value of attribute height.



7
8
9
# File 'lib/image_info/image.rb', line 7

def height
  @height
end

#typeObject

Returns the value of attribute type.



7
8
9
# File 'lib/image_info/image.rb', line 7

def type
  @type
end

#uriObject (readonly)

Returns the value of attribute uri.



6
7
8
# File 'lib/image_info/image.rb', line 6

def uri
  @uri
end

#widthObject

Returns the value of attribute width.



7
8
9
# File 'lib/image_info/image.rb', line 7

def width
  @width
end

Instance Method Details

#sizeObject



13
14
15
# File 'lib/image_info/image.rb', line 13

def size
  [width, height].compact
end

#valid?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/image_info/image.rb', line 17

def valid?
  uri.is_a?(::URI::HTTP)
end