Class: Ifilter::Input
- Inherits:
-
Object
- Object
- Ifilter::Input
- Defined in:
- lib/ifilter/input.rb
Instance Attribute Summary collapse
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #<<(text) ⇒ Object
- #backspace! ⇒ Object
- #filter(array) ⇒ Object
-
#initialize(text = '') ⇒ Input
constructor
A new instance of Input.
- #size ⇒ Object
- #to_regexp ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(text = '') ⇒ Input
Returns a new instance of Input.
5 6 7 |
# File 'lib/ifilter/input.rb', line 5 def initialize(text = '') @text = text end |
Instance Attribute Details
#text ⇒ Object
Returns the value of attribute text.
3 4 5 |
# File 'lib/ifilter/input.rb', line 3 def text @text end |
Instance Method Details
#<<(text) ⇒ Object
9 10 11 |
# File 'lib/ifilter/input.rb', line 9 def <<(text) @text << text end |
#backspace! ⇒ Object
17 18 19 |
# File 'lib/ifilter/input.rb', line 17 def backspace! @text.chop! end |
#filter(array) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/ifilter/input.rb', line 31 def filter(array) array.each_with_object([]) do |str, outputs| regexp = self.to_regexp if !regexp.nil? && regexp =~ str outputs << str end end end |
#size ⇒ Object
13 14 15 |
# File 'lib/ifilter/input.rb', line 13 def size @text.size end |
#to_regexp ⇒ Object
25 26 27 28 29 |
# File 'lib/ifilter/input.rb', line 25 def to_regexp /#{@text}/i rescue nil end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/ifilter/input.rb', line 21 def to_s @text end |