Module: FaviconMaker::InputValidator
- Defined in:
- lib/favicon_maker/input_validator.rb
Class Method Summary collapse
- .format_multi_resolution?(format) ⇒ Boolean
- .size_square?(size) ⇒ Boolean
- .valid_format?(format) ⇒ Boolean
- .valid_size?(size, multiple = false) ⇒ Boolean
Class Method Details
.format_multi_resolution?(format) ⇒ Boolean
13 14 15 |
# File 'lib/favicon_maker/input_validator.rb', line 13 def self.format_multi_resolution?(format) format.to_s == "ico" end |
.size_square?(size) ⇒ Boolean
21 22 23 24 |
# File 'lib/favicon_maker/input_validator.rb', line 21 def self.size_square?(size) width, height = *size.split('x').map(&:to_i) width == height end |
.valid_format?(format) ⇒ Boolean
17 18 19 |
# File 'lib/favicon_maker/input_validator.rb', line 17 def self.valid_format?(format) ["ico", "png"].include?(format.to_s) end |
.valid_size?(size, multiple = false) ⇒ Boolean
5 6 7 8 9 10 11 |
# File 'lib/favicon_maker/input_validator.rb', line 5 def self.valid_size?(size, multiple=false) matches = size =~ /^(\d+)/ && size.scan(/(\d+x\d+)/) return false if matches.nil? || matches.empty? return true if multiple && matches.size >= 1 return true if matches.size == 1 false end |