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
  initialize_builtins!
  @input_stream = InputStream.new(io)
  @input_stream.add_observer(self)
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

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