Class: RussianPost::Captcha::Patterns
- Inherits:
-
Object
- Object
- RussianPost::Captcha::Patterns
- Defined in:
- lib/russian_post/captcha/patterns.rb
Instance Attribute Summary collapse
-
#patterns ⇒ Object
readonly
Returns the value of attribute patterns.
Class Method Summary collapse
Instance Method Summary collapse
- #add(pattern) ⇒ Object
- #each(&block) ⇒ Object
- #find(image, x, y) ⇒ Object
-
#initialize(file) ⇒ Patterns
constructor
A new instance of Patterns.
Constructor Details
#initialize(file) ⇒ Patterns
Returns a new instance of Patterns.
14 15 16 |
# File 'lib/russian_post/captcha/patterns.rb', line 14 def initialize(file) @patterns = load_patterns(file) end |
Instance Attribute Details
#patterns ⇒ Object (readonly)
Returns the value of attribute patterns.
4 5 6 |
# File 'lib/russian_post/captcha/patterns.rb', line 4 def patterns @patterns end |
Class Method Details
.built_in ⇒ Object
8 9 10 |
# File 'lib/russian_post/captcha/patterns.rb', line 8 def built_in @builtin_patterns ||= RussianPost::Captcha::Patterns.new(File.('characters.dat', File.dirname(__FILE__))) end |
Instance Method Details
#add(pattern) ⇒ Object
22 23 24 |
# File 'lib/russian_post/captcha/patterns.rb', line 22 def add(pattern) @patterns << pattern end |
#each(&block) ⇒ Object
18 19 20 |
# File 'lib/russian_post/captcha/patterns.rb', line 18 def each(&block) @patterns.each(&block) end |
#find(image, x, y) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/russian_post/captcha/patterns.rb', line 26 def find(image, x, y) each do |pattern| return pattern if pattern.match?(image, x, y) end return false end |