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.
-
#rs ⇒ Object
readonly
Returns the value of attribute rs.
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 initialize_builtins! @input_stream = InputStream.new(io) @input_stream.add_observer(self) 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 |
#rs ⇒ Object (readonly)
Returns the value of attribute rs.
6 7 8 |
# File 'lib/rawk/rawk.rb', line 6 def rs @rs end |
Instance Method Details
#every(&block) ⇒ Object
38 39 40 |
# File 'lib/rawk/rawk.rb', line 38 def every(&block) @every << block end |
#finish(&block) ⇒ Object
42 43 44 |
# File 'lib/rawk/rawk.rb', line 42 def finish(&block) @finish << block end |
#on_new_line ⇒ Object Also known as: update
23 24 25 |
# File 'lib/rawk/rawk.rb', line 23 def on_new_line @nr += 1 end |
#run(code = "", &block) ⇒ Object
28 29 30 31 |
# File 'lib/rawk/rawk.rb', line 28 def run(code = "", &block) load!(code, &block) execute_code! end |
#start(&block) ⇒ Object
DSL
34 35 36 |
# File 'lib/rawk/rawk.rb', line 34 def start(&block) @start << block end |