Class: Ficon::Image
- Inherits:
-
Object
- Object
- Ficon::Image
- Defined in:
- lib/ficon/image.rb
Instance Attribute Summary collapse
-
#area ⇒ Object
readonly
Returns the value of attribute area.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#tile_color ⇒ Object
readonly
Returns the value of attribute tile_color.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url, tile_color = nil) ⇒ Image
constructor
A new instance of Image.
- #to_s ⇒ Object
Constructor Details
#initialize(url, tile_color = nil) ⇒ Image
Returns a new instance of Image.
8 9 10 11 12 13 14 15 16 |
# File 'lib/ficon/image.rb', line 8 def initialize(url, tile_color = nil) @url = url @tile_color = tile_color c = Cache.new(@url) cached_size = Cache.new(url).data @size = cached_size ? JSON.parse(cached_size) : FastImage.size(url) c.data = @size.to_json if @size @area = @size&.inject(&:*) || 0 end |
Instance Attribute Details
#area ⇒ Object (readonly)
Returns the value of attribute area.
7 8 9 |
# File 'lib/ficon/image.rb', line 7 def area @area end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
7 8 9 |
# File 'lib/ficon/image.rb', line 7 def size @size end |
#tile_color ⇒ Object (readonly)
Returns the value of attribute tile_color.
7 8 9 |
# File 'lib/ficon/image.rb', line 7 def tile_color @tile_color end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/ficon/image.rb', line 7 def url @url end |
Instance Method Details
#to_s ⇒ Object
18 19 20 21 22 |
# File 'lib/ficon/image.rb', line 18 def to_s result = @url.to_s + " (#{@size})" result += " [#{@tile_color}]" if @tile_color result end |