Class: RubyMarks::Mark
- Inherits:
-
Object
- Object
- RubyMarks::Mark
- Defined in:
- lib/ruby_marks/mark.rb
Instance Attribute Summary collapse
-
#coordinates ⇒ Object
Returns the value of attribute coordinates.
-
#distance_from_previous ⇒ Object
Returns the value of attribute distance_from_previous.
-
#group ⇒ Object
Returns the value of attribute group.
-
#image_str ⇒ Object
Returns the value of attribute image_str.
-
#line ⇒ Object
Returns the value of attribute line.
-
#position ⇒ Object
Returns the value of attribute position.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Mark
constructor
A new instance of Mark.
- #intensity ⇒ Object
- #marked? ⇒ Boolean
- #unmarked? ⇒ Boolean
- #value ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Mark
Returns a new instance of Mark.
7 8 9 10 11 |
# File 'lib/ruby_marks/mark.rb', line 7 def initialize(params={}) params.each do |k, v| self.send("#{k}=", v) if self.respond_to?("#{k}=") end end |
Instance Attribute Details
#coordinates ⇒ Object
Returns the value of attribute coordinates.
5 6 7 |
# File 'lib/ruby_marks/mark.rb', line 5 def coordinates @coordinates end |
#distance_from_previous ⇒ Object
Returns the value of attribute distance_from_previous.
5 6 7 |
# File 'lib/ruby_marks/mark.rb', line 5 def distance_from_previous @distance_from_previous end |
#group ⇒ Object
Returns the value of attribute group.
5 6 7 |
# File 'lib/ruby_marks/mark.rb', line 5 def group @group end |
#image_str ⇒ Object
Returns the value of attribute image_str.
5 6 7 |
# File 'lib/ruby_marks/mark.rb', line 5 def image_str @image_str end |
#line ⇒ Object
Returns the value of attribute line.
5 6 7 |
# File 'lib/ruby_marks/mark.rb', line 5 def line @line end |
#position ⇒ Object
Returns the value of attribute position.
5 6 7 |
# File 'lib/ruby_marks/mark.rb', line 5 def position @position end |
Instance Method Details
#intensity ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ruby_marks/mark.rb', line 19 def intensity if @image_str colors = [] @image_str.each do |y| y.each do |x| colors << x end end intensity = colors.count(".") * 100 / colors.size end end |
#marked? ⇒ Boolean
13 14 15 16 17 |
# File 'lib/ruby_marks/mark.rb', line 13 def marked? if @image_str return intensity >= @group.recognizer.config.intensity_percentual end end |
#unmarked? ⇒ Boolean
33 34 35 |
# File 'lib/ruby_marks/mark.rb', line 33 def unmarked? !marked? end |
#value ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/ruby_marks/mark.rb', line 37 def value if @group position = @group.marks[line].index(self) values = @group. return position && values[position] end end |