Class: Cul::Image::Properties::Exif::Ratio
- Inherits:
-
Object
- Object
- Cul::Image::Properties::Exif::Ratio
- Defined in:
- lib/cul_image_props/image/properties/exif/types.rb
Instance Attribute Summary collapse
-
#den ⇒ Object
ratio object that eventually will be able to reduce itself to lowest common denominator for printing.
-
#num ⇒ Object
ratio object that eventually will be able to reduce itself to lowest common denominator for printing.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(num, den) ⇒ Ratio
constructor
A new instance of Ratio.
- #inspect ⇒ Object
- #reduce ⇒ Object
Constructor Details
#initialize(num, den) ⇒ Ratio
Returns a new instance of Ratio.
72 73 74 75 |
# File 'lib/cul_image_props/image/properties/exif/types.rb', line 72 def initialize(num, den) @num = num @den = den end |
Instance Attribute Details
#den ⇒ Object
ratio object that eventually will be able to reduce itself to lowest common denominator for printing
61 62 63 |
# File 'lib/cul_image_props/image/properties/exif/types.rb', line 61 def den @den end |
#num ⇒ Object
ratio object that eventually will be able to reduce itself to lowest common denominator for printing
61 62 63 |
# File 'lib/cul_image_props/image/properties/exif/types.rb', line 61 def num @num end |
Class Method Details
.gcd(a, b) ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/cul_image_props/image/properties/exif/types.rb', line 62 def self.gcd(a, b) if b == 1 or a == 1 return 1 elsif b == 0 return a else return gcd(b, a % b) end end |
Instance Method Details
#inspect ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/cul_image_props/image/properties/exif/types.rb', line 77 def inspect self.reduce() if @den == 1 return self.num.to_s end return format("%d/%d", @num, @den) end |