Class: Nagoro::Pipe::Base
- Inherits:
-
Object
- Object
- Nagoro::Pipe::Base
show all
- Defined in:
- lib/nagoro/pipe/base.rb
Instance Method Summary
collapse
Constructor Details
#initialize(io) ⇒ Base
Returns a new instance of Base.
4
5
6
7
|
# File 'lib/nagoro/pipe/base.rb', line 4
def initialize(io)
@body, @stack = [], []
@scanner = Scanner.new(io, self)
end
|
Instance Method Details
#append(string) ⇒ Object
30
31
32
|
# File 'lib/nagoro/pipe/base.rb', line 30
def append(string)
@body << string
end
|
#doctype(string) ⇒ Object
42
43
44
45
|
# File 'lib/nagoro/pipe/base.rb', line 42
def doctype(string)
string.strip!
append "<!DOCTYPE #{string}>"
end
|
#instruction(name, instruction) ⇒ Object
34
35
36
|
# File 'lib/nagoro/pipe/base.rb', line 34
def instruction(name, instruction)
append "<?#{name} #{instruction.to_s.strip} ?>"
end
|
#result ⇒ Object
9
10
11
12
|
# File 'lib/nagoro/pipe/base.rb', line 9
def result
@scanner.stream
@body.join
end
|
#tag(tag, original_attrs, value_attrs) ⇒ Object
14
15
16
|
# File 'lib/nagoro/pipe/base.rb', line 14
def tag(tag, original_attrs, value_attrs)
append "#{tag_with(tag, original_attrs)} />"
end
|
#tag_end(tag) ⇒ Object
22
23
24
|
# File 'lib/nagoro/pipe/base.rb', line 22
def tag_end(tag)
append "</#{tag}>"
end
|
#tag_start(tag, original_attrs, value_attrs) ⇒ Object
18
19
20
|
# File 'lib/nagoro/pipe/base.rb', line 18
def tag_start(tag, original_attrs, value_attrs)
append "#{tag_with(tag, original_attrs)}>"
end
|
#tag_with(tag, hash) ⇒ Object
38
39
40
|
# File 'lib/nagoro/pipe/base.rb', line 38
def tag_with(tag, hash)
"<#{tag}#{hash.map{|k,v| (v == nil) ? %( #{k}) : %( #{k}=#{v}) }.join}"
end
|
#text(string) ⇒ Object
26
27
28
|
# File 'lib/nagoro/pipe/base.rb', line 26
def text(string)
append(string)
end
|