Class: ColorProximity
- Inherits:
-
Object
- Object
- ColorProximity
- Defined in:
- lib/color-proximity.rb,
lib/color-proximity/version.rb
Constant Summary collapse
- VERSION =
'0.2.1'
Instance Attribute Summary collapse
-
#collection ⇒ Object
Returns the value of attribute collection.
-
#threshold ⇒ Object
Returns the value of attribute threshold.
Instance Method Summary collapse
-
#initialize(threshold, collection) ⇒ ColorProximity
constructor
A new instance of ColorProximity.
- #past_threshold?(color) ⇒ Boolean
- #thresholds(color) ⇒ Object
Constructor Details
#initialize(threshold, collection) ⇒ ColorProximity
Returns a new instance of ColorProximity.
8 9 10 11 |
# File 'lib/color-proximity.rb', line 8 def initialize(threshold, collection) @threshold = threshold @collection = collection end |
Instance Attribute Details
#collection ⇒ Object
Returns the value of attribute collection.
6 7 8 |
# File 'lib/color-proximity.rb', line 6 def collection @collection end |
#threshold ⇒ Object
Returns the value of attribute threshold.
6 7 8 |
# File 'lib/color-proximity.rb', line 6 def threshold @threshold end |
Instance Method Details
#past_threshold?(color) ⇒ Boolean
13 14 15 16 17 18 19 20 21 |
# File 'lib/color-proximity.rb', line 13 def past_threshold?(color) @collection.each_with_object([true]) do |collection_color, arr| proximity = proximity_of(color, collection_color) next unless @threshold > proximity arr[0] = false arr[1] = [] if arr[1].nil? arr[1] << collection_color end end |
#thresholds(color) ⇒ Object
23 24 25 |
# File 'lib/color-proximity.rb', line 23 def thresholds(color) @collection.map { |collection_color| proximity_of(color, collection_color) } end |