Class: Rawk::Program
- Inherits:
-
Object
- Object
- Rawk::Program
- Defined in:
- lib/rawk/rawk.rb
Instance Attribute Summary collapse
-
#fs ⇒ Object
readonly
Returns the value of attribute fs.
Instance Method Summary collapse
- #every(&block) ⇒ Object
- #finish(&block) ⇒ Object
-
#initialize(io) ⇒ Program
constructor
A new instance of Program.
- #on_new_line ⇒ Object (also: #update)
- #run(code = "", &block) ⇒ Object
-
#start(&block) ⇒ Object
DSL.
Constructor Details
#initialize(io) ⇒ Program
Returns a new instance of Program.
8 9 10 11 12 13 |
# File 'lib/rawk/rawk.rb', line 8 def initialize(io) @start, @every, @finish = Set.new, Set.new, Set.new @input_stream = InputStream.new(io) @input_stream.add_observer(self) initialize_builtins! end |
Instance Attribute Details
#fs ⇒ Object (readonly)
Returns the value of attribute fs.
6 7 8 |
# File 'lib/rawk/rawk.rb', line 6 def fs @fs end |
Instance Method Details
#every(&block) ⇒ Object
37 38 39 |
# File 'lib/rawk/rawk.rb', line 37 def every(&block) @every << block end |
#finish(&block) ⇒ Object
41 42 43 |
# File 'lib/rawk/rawk.rb', line 41 def finish(&block) @finish << block end |
#on_new_line ⇒ Object Also known as: update
22 23 24 |
# File 'lib/rawk/rawk.rb', line 22 def on_new_line @nr += 1 end |
#run(code = "", &block) ⇒ Object
27 28 29 30 |
# File 'lib/rawk/rawk.rb', line 27 def run(code = "", &block) load!(code, &block) execute_code! end |
#start(&block) ⇒ Object
DSL
33 34 35 |
# File 'lib/rawk/rawk.rb', line 33 def start(&block) @start << block end |