Class: Pixel

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

Instance Method Summary collapse

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

#highObject



9
10
11
12
# File 'lib/pixel/pixel.rb', line 9

def high
  @wide = nil
  freeze
end

#wideObject



18
19
20
21
# File 'lib/pixel/pixel.rb', line 18

def wide
  @high = nil
  freeze
end