Class: OOXL::Comments
- Inherits:
-
Object
- Object
- OOXL::Comments
- Defined in:
- lib/ooxl/xl_objects/comments.rb
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
Returns the value of attribute comments.
Class Method Summary collapse
Instance Method Summary collapse
- #[](id) ⇒ Object
-
#initialize(comments) ⇒ Comments
constructor
A new instance of Comments.
Constructor Details
#initialize(comments) ⇒ Comments
Returns a new instance of Comments.
5 6 7 |
# File 'lib/ooxl/xl_objects/comments.rb', line 5 def initialize(comments) @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
Returns the value of attribute comments.
3 4 5 |
# File 'lib/ooxl/xl_objects/comments.rb', line 3 def comments @comments end |
Class Method Details
.load_from_stream(comment_xml) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ooxl/xl_objects/comments.rb', line 13 def self.load_from_stream(comment_xml) comment_xml =Nokogiri.XML(comment_xml).remove_namespaces! comments = comment_xml.xpath("//comments/commentList/comment").map do |comment_node| comment_text_node = comment_node.xpath('./text/r/t') value = if comment_text_node.is_a?(Array) comment_text_node.map { |comment_text_node| comment_text_node.text }.join('') else comment_text_node.text end id = comment_node.attributes["ref"].to_s [id, value] end.to_h new(comments) end |
Instance Method Details
#[](id) ⇒ Object
9 10 11 |
# File 'lib/ooxl/xl_objects/comments.rb', line 9 def [](id) @comments[id] end |