Class: Insika::Refinement::Candidate
- Inherits:
-
Data
- Object
- Data
- Insika::Refinement::Candidate
- Defined in:
- lib/insika/refinement/candidate.rb
Instance Attribute Summary collapse
-
#dropped ⇒ Object
readonly
Returns the value of attribute dropped.
-
#edits ⇒ Object
readonly
Returns the value of attribute edits.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#proposer ⇒ Object
readonly
Returns the value of attribute proposer.
-
#rationale ⇒ Object
readonly
Returns the value of attribute rationale.
Instance Method Summary collapse
-
#apply(contents) ⇒ Object
name => new content, for the files this candidate touches.
- #empty? ⇒ Boolean
- #files ⇒ Object
- #to_h ⇒ Object
Instance Attribute Details
#dropped ⇒ Object (readonly)
Returns the value of attribute dropped
48 49 50 |
# File 'lib/insika/refinement/candidate.rb', line 48 def dropped @dropped end |
#edits ⇒ Object (readonly)
Returns the value of attribute edits
48 49 50 |
# File 'lib/insika/refinement/candidate.rb', line 48 def edits @edits end |
#id ⇒ Object (readonly)
Returns the value of attribute id
48 49 50 |
# File 'lib/insika/refinement/candidate.rb', line 48 def id @id end |
#proposer ⇒ Object (readonly)
Returns the value of attribute proposer
48 49 50 |
# File 'lib/insika/refinement/candidate.rb', line 48 def proposer @proposer end |
#rationale ⇒ Object (readonly)
Returns the value of attribute rationale
48 49 50 |
# File 'lib/insika/refinement/candidate.rb', line 48 def rationale @rationale end |
Instance Method Details
#apply(contents) ⇒ Object
name => new content, for the files this candidate touches. Edits to the same file compose in order, so two edits to TOOLS.md both land.
54 55 56 57 58 59 60 |
# File 'lib/insika/refinement/candidate.rb', line 54 def apply(contents) edits.each_with_object({}) do |edit, acc| current = acc[edit.file] || contents[edit.file] applied = edit.apply_to(current) acc[edit.file] = applied unless applied.nil? end end |
#empty? ⇒ Boolean
49 |
# File 'lib/insika/refinement/candidate.rb', line 49 def empty? = edits.empty? |
#files ⇒ Object
50 |
# File 'lib/insika/refinement/candidate.rb', line 50 def files = edits.map(&:file).uniq |
#to_h ⇒ Object
62 63 |
# File 'lib/insika/refinement/candidate.rb', line 62 def to_h = { "id" => id, "proposer" => proposer, "rationale" => rationale, "edits" => edits.map(&:to_h), "dropped" => dropped.map(&:to_h) } |