Class: Sablon::Content::String
- Inherits:
-
Struct
- Object
- Struct
- Sablon::Content::String
show all
- Includes:
- Sablon::Content
- Defined in:
- lib/sablon/content.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
make, register, remove, wrap
Constructor Details
#initialize(value) ⇒ String
Returns a new instance of String.
50
51
52
|
# File 'lib/sablon/content.rb', line 50
def initialize(value)
super value.to_s
end
|
Instance Attribute Details
#string ⇒ Object
Returns the value of attribute string
43
44
45
|
# File 'lib/sablon/content.rb', line 43
def string
@string
end
|
Class Method Details
.id ⇒ Object
45
|
# File 'lib/sablon/content.rb', line 45
def self.id; :string end
|
.wraps?(value) ⇒ Boolean
46
47
48
|
# File 'lib/sablon/content.rb', line 46
def self.wraps?(value)
value.respond_to?(:to_s)
end
|
Instance Method Details
#append_to(paragraph, display_node) ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/sablon/content.rb', line 54
def append_to(paragraph, display_node)
string.scan(/[^\n]+|\n/).reverse.each do |part|
if part == "\n"
display_node.add_next_sibling Nokogiri::XML::Node.new "w:br", display_node.document
else
text_part = display_node.dup
text_part.content = part
display_node.add_next_sibling text_part
end
end
end
|