Class: Ape::Crumbs
- Inherits:
-
Object
- Object
- Ape::Crumbs
- Defined in:
- lib/ape/crumbs.rb
Instance Method Summary collapse
- #<<(data) ⇒ Object
- #each ⇒ Object
- #grep(pattern) ⇒ Object
-
#initialize ⇒ Crumbs
constructor
A new instance of Crumbs.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Crumbs
Returns a new instance of Crumbs.
11 12 13 14 |
# File 'lib/ape/crumbs.rb', line 11 def initialize @crumbs = [] @keep_next = false end |
Instance Method Details
#<<(data) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ape/crumbs.rb', line 20 def << data if @keep_next @crumbs << "> #{data}" @keep_next = false elsif data =~ /^->/ @crumbs << "< #{data.gsub(/^.../, '')}" elsif data =~ /^<-/ @keep_next = true end end |
#each ⇒ Object
31 32 33 |
# File 'lib/ape/crumbs.rb', line 31 def each @crumbs.each { |c| yield c } end |
#grep(pattern) ⇒ Object
16 17 18 |
# File 'lib/ape/crumbs.rb', line 16 def grep(pattern) @crumbs.grep(pattern) end |
#to_s ⇒ Object
35 36 37 |
# File 'lib/ape/crumbs.rb', line 35 def to_s " " + @crumbs.join("...\n") end |