Module: BodyWriter

Defined in:
lib/dsl.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(obj) ⇒ Object



5
6
7
# File 'lib/dsl.rb', line 5

def self.extended obj
  obj.instance_variable_set(:@body, "")
end

Instance Method Details

#bodyObject



23
24
25
# File 'lib/dsl.rb', line 23

def body
  @body
end

#body=(value) ⇒ Object



26
27
28
# File 'lib/dsl.rb', line 26

def body=(value)
  @body = value
end

#command(cmd) ⇒ Object



20
21
22
# File 'lib/dsl.rb', line 20

def command cmd
  write `#{cmd.to_s}`
end


11
12
13
# File 'lib/dsl.rb', line 11

def print str
  @body << str.to_s
end

#printf(*p) ⇒ Object



17
18
19
# File 'lib/dsl.rb', line 17

def printf *p
  @body << (sprintf *p)
end

#puts(str) ⇒ Object



14
15
16
# File 'lib/dsl.rb', line 14

def puts str
  @body << str.to_s << "\n"
end

#write(str) ⇒ Object



8
9
10
# File 'lib/dsl.rb', line 8

def write str
  @body << str.to_s
end