Class: Rawk::Program

Inherits:
Object
  • Object
show all
Defined in:
lib/rawk/rawk.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#fsObject (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_lineObject 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