Class: Monet::Changeset
- Inherits:
-
Object
- Object
- Monet::Changeset
- Defined in:
- lib/monet/changeset.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #image ⇒ Object
-
#initialize(base_image, pixel_array, path) ⇒ Changeset
constructor
A new instance of Changeset.
- #modified? ⇒ Boolean
- #percentage_changed ⇒ Object
- #pixels_changed ⇒ Object
Constructor Details
#initialize(base_image, pixel_array, path) ⇒ Changeset
Returns a new instance of Changeset.
5 6 7 8 9 |
# File 'lib/monet/changeset.rb', line 5 def initialize(base_image, pixel_array, path) @base_image = base_image @changed_pixels = pixel_array @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/monet/changeset.rb', line 3 def path @path end |
Instance Method Details
#image ⇒ Object
11 12 13 |
# File 'lib/monet/changeset.rb', line 11 def image Monet::Image.new @path end |
#modified? ⇒ Boolean
15 16 17 |
# File 'lib/monet/changeset.rb', line 15 def modified? pixels_changed > 0 end |
#percentage_changed ⇒ Object
23 24 25 |
# File 'lib/monet/changeset.rb', line 23 def percentage_changed ((pixels_changed.to_f / @base_image.area.to_f) * 100).round(2) end |
#pixels_changed ⇒ Object
19 20 21 |
# File 'lib/monet/changeset.rb', line 19 def pixels_changed @changed_pixels.count end |