Class: HtmlSurgeon::ChangeSet
- Inherits:
-
Object
- Object
- HtmlSurgeon::ChangeSet
- Defined in:
- lib/html_surgeon/change_set.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#change_list ⇒ Object
readonly
Returns the value of attribute change_list.
-
#node_set ⇒ Object
readonly
Returns the value of attribute node_set.
-
#refinement_callbacks ⇒ Object
readonly
Returns the value of attribute refinement_callbacks.
-
#run_time ⇒ Object
readonly
Returns the value of attribute run_time.
Class Method Summary collapse
Instance Method Summary collapse
- #changes ⇒ Object
-
#id(custom_id = nil) ⇒ Object
chainable fluid ID setter.
-
#initialize(node_set, base) ⇒ ChangeSet
constructor
A new instance of ChangeSet.
- #reject(&block) ⇒ Object
- #run ⇒ Object
- #select(&block) ⇒ Object
Constructor Details
#initialize(node_set, base) ⇒ ChangeSet
Returns a new instance of ChangeSet.
18 19 20 21 22 23 24 25 |
# File 'lib/html_surgeon/change_set.rb', line 18 def initialize(node_set, base) @node_set = node_set @base = base @change_list = [] @id = SecureRandom.uuid @run_time = nil @refinement_callbacks = [] end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
4 5 6 |
# File 'lib/html_surgeon/change_set.rb', line 4 def base @base end |
#change_list ⇒ Object (readonly)
Returns the value of attribute change_list.
4 5 6 |
# File 'lib/html_surgeon/change_set.rb', line 4 def change_list @change_list end |
#node_set ⇒ Object (readonly)
Returns the value of attribute node_set.
4 5 6 |
# File 'lib/html_surgeon/change_set.rb', line 4 def node_set @node_set end |
#refinement_callbacks ⇒ Object (readonly)
Returns the value of attribute refinement_callbacks.
4 5 6 |
# File 'lib/html_surgeon/change_set.rb', line 4 def refinement_callbacks @refinement_callbacks end |
#run_time ⇒ Object (readonly)
Returns the value of attribute run_time.
4 5 6 |
# File 'lib/html_surgeon/change_set.rb', line 4 def run_time @run_time end |
Class Method Details
.create(node_set, base) ⇒ Object
6 7 8 |
# File 'lib/html_surgeon/change_set.rb', line 6 def self.create(node_set, base) new_class.new node_set, base end |
.new_class ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/html_surgeon/change_set.rb', line 10 def self.new_class Class.new(ChangeSet) do Changes.change_classes.each do |klass| include klass::ChangeSetMethods end end end |
Instance Method Details
#changes ⇒ Object
51 52 53 |
# File 'lib/html_surgeon/change_set.rb', line 51 def changes change_list.map &:log end |
#id(custom_id = nil) ⇒ Object
chainable fluid ID setter
32 33 34 35 36 37 38 39 |
# File 'lib/html_surgeon/change_set.rb', line 32 def id(custom_id = nil) if custom_id @id = custom_id self else @id end end |
#reject(&block) ⇒ Object
60 61 62 63 |
# File 'lib/html_surgeon/change_set.rb', line 60 def reject(&block) refinement_callbacks << [:reject, block] self end |
#run ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/html_surgeon/change_set.rb', line 41 def run @run_time = Time.now.utc node_set.each do |node| apply_on_node(node) end self end |
#select(&block) ⇒ Object
55 56 57 58 |
# File 'lib/html_surgeon/change_set.rb', line 55 def select(&block) refinement_callbacks << [:select, block] self end |