Class: Pixel
- Inherits:
-
Object
- Object
- Pixel
- Defined in:
- lib/pixel/pixel.rb
Instance Method Summary collapse
- #calculate(dimensions = nil) ⇒ Object
- #high ⇒ Object
-
#initialize(number) ⇒ Pixel
constructor
A new instance of Pixel.
- #wide ⇒ Object
Constructor Details
#initialize(number) ⇒ Pixel
Returns a new instance of Pixel.
14 15 16 |
# File 'lib/pixel/pixel.rb', line 14 def initialize number @high = @wide = number end |
Instance Method Details
#calculate(dimensions = nil) ⇒ Object
2 3 4 5 6 7 |
# File 'lib/pixel/pixel.rb', line 2 def calculate dimensions = nil [ @high || ( @wide.to_f / ratio(dimensions) ).to_i, @wide || ( @high.to_f * ratio(dimensions) ).to_i ] end |
#high ⇒ Object
9 10 11 12 |
# File 'lib/pixel/pixel.rb', line 9 def high @wide = nil freeze end |
#wide ⇒ Object
18 19 20 21 |
# File 'lib/pixel/pixel.rb', line 18 def wide @high = nil freeze end |