Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Remove monkey patching on Module #130

Merged
merged 2 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/docx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ module Docx #:nodoc:
autoload :Document, 'docx/document'
end

require 'docx/core_ext/module'
172 changes: 0 additions & 172 deletions lib/docx/core_ext/module.rb

This file was deleted.

11 changes: 9 additions & 2 deletions lib/docx/elements/element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@ def self.included(base)
end

attr_accessor :node
delegate :at_xpath, :xpath, :to => :@node

# TODO: Should create a docx object from this
def parent(type = '*')
@node.at_xpath("./parent::#{type}")
end

def at_xpath(*args)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arguments match what is expected in the docs

@node.at_xpath(*args)
end

def xpath(*args)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arguments match what is expected in the docs

@node.xpath(*args)
end

# Get parent paragraph of element
def parent_paragraph
Elements::Containers::Paragraph.new(parent('w:p'))
Expand Down Expand Up @@ -102,4 +109,4 @@ def create_within(element)
end
end
end
end
end
10 changes: 8 additions & 2 deletions lib/docx/elements/text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@ module Docx
module Elements
class Text
include Element
delegate :content, :content=, :to => :@node

def self.tag
't'
end

def content
@node.content
end

def content=(args)
@node.content = args
end

def initialize(node)
@node = node
end
end
end
end
end