Class: FeaturedImage::Criteria
- Inherits:
-
Object
- Object
- FeaturedImage::Criteria
- Defined in:
- lib/featuredimage/finder.rb
Instance Attribute Summary collapse
-
#aspect_range ⇒ Object
Returns the value of attribute aspect_range.
-
#max_height ⇒ Object
Returns the value of attribute max_height.
-
#max_width ⇒ Object
Returns the value of attribute max_width.
-
#min_height ⇒ Object
Returns the value of attribute min_height.
-
#min_width ⇒ Object
Returns the value of attribute min_width.
Instance Method Summary collapse
- #check(size) ⇒ Object
-
#initialize(*args) ⇒ Criteria
constructor
A new instance of Criteria.
Constructor Details
#initialize(*args) ⇒ Criteria
Returns a new instance of Criteria.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/featuredimage/finder.rb', line 127 def initialize(*args) # default criteria size 0x0 to 4096x4096 @min_width = 0 @max_width = 4096 @min_height = 0 @max_height = 4096 @aspect_range = 0..4096 case args.length when 0 # default criteria when 1 @aspect_range = args[0] when 2 @min_width = args[0] @min_height = args[1] when 3 @min_width = args[0] @min_height = args[1] @aspect_range = args[2] when 4 @min_width = args[0] @max_width = args[1] @min_height = args[2] @max_height = args[3] when 5 @min_width = args[0] @max_width = args[1] @min_height = args[2] @max_height = args[3] @aspect_range = args[4] else raise ArgumentError.new end end |
Instance Attribute Details
#aspect_range ⇒ Object
Returns the value of attribute aspect_range.
125 126 127 |
# File 'lib/featuredimage/finder.rb', line 125 def aspect_range @aspect_range end |
#max_height ⇒ Object
Returns the value of attribute max_height.
125 126 127 |
# File 'lib/featuredimage/finder.rb', line 125 def max_height @max_height end |
#max_width ⇒ Object
Returns the value of attribute max_width.
125 126 127 |
# File 'lib/featuredimage/finder.rb', line 125 def max_width @max_width end |
#min_height ⇒ Object
Returns the value of attribute min_height.
125 126 127 |
# File 'lib/featuredimage/finder.rb', line 125 def min_height @min_height end |
#min_width ⇒ Object
Returns the value of attribute min_width.
125 126 127 |
# File 'lib/featuredimage/finder.rb', line 125 def min_width @min_width end |
Instance Method Details
#check(size) ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/featuredimage/finder.rb', line 163 def check(size) if @min_width < size.width and size.width < @max_width and @min_height < size.height and size.height < @max_height and @aspect_range.include?(size.aspect) true else false end end |