Class: HTMLComponent::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/html-native/builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(strings = []) ⇒ Builder

Returns a new instance of Builder.



4
5
6
7
8
9
10
# File 'lib/html-native/builder.rb', line 4

def initialize(strings = [])
  if strings.kind_of? String 
    @strings = [strings]
  else
    @strings = strings.dup
  end
end

Instance Method Details

#+(string) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/html-native/builder.rb', line 12

def +(string)
  if string.kind_of? Builder 
    @strings << string
  elsif string.kind_of? HTMLComponent
    @strings << string.render
  else
    @strings << string.to_s
  end
  self
end

#to_sObject Also known as: to_str



23
24
25
# File 'lib/html-native/builder.rb', line 23

def to_s
  @strings.join
end