Class: Snaptoken::Step
- Inherits:
-
Object
- Object
- Snaptoken::Step
- Defined in:
- lib/snaptoken/step.rb
Instance Attribute Summary collapse
-
#diffs ⇒ Object
Returns the value of attribute diffs.
-
#number ⇒ Object
Returns the value of attribute number.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(number, summary, text, diffs) ⇒ Step
constructor
A new instance of Step.
- #syntax_highlight! ⇒ Object
- #to_html(tutorial, offline) ⇒ Object
- #to_patch(options = {}) ⇒ Object
Constructor Details
#initialize(number, summary, text, diffs) ⇒ Step
Returns a new instance of Step.
4 5 6 7 8 9 |
# File 'lib/snaptoken/step.rb', line 4 def initialize(number, summary, text, diffs) @number = number @summary = summary.strip @text = text.strip @diffs = diffs end |
Instance Attribute Details
#diffs ⇒ Object
Returns the value of attribute diffs.
2 3 4 |
# File 'lib/snaptoken/step.rb', line 2 def diffs @diffs end |
#number ⇒ Object
Returns the value of attribute number.
2 3 4 |
# File 'lib/snaptoken/step.rb', line 2 def number @number end |
#summary ⇒ Object
Returns the value of attribute summary.
2 3 4 |
# File 'lib/snaptoken/step.rb', line 2 def summary @summary end |
#text ⇒ Object
Returns the value of attribute text.
2 3 4 |
# File 'lib/snaptoken/step.rb', line 2 def text @text end |
Instance Method Details
#syntax_highlight! ⇒ Object
24 25 26 |
# File 'lib/snaptoken/step.rb', line 24 def syntax_highlight! @diffs.each(&:syntax_highlight!) end |
#to_html(tutorial, offline) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/snaptoken/step.rb', line 11 def to_html(tutorial, offline) Snaptoken::Template.new(tutorial.step_template, tutorial, offline: offline, number: @number, summary: @summary, diffs: @diffs ).render_template end |
#to_patch(options = {}) ⇒ Object
20 21 22 |
# File 'lib/snaptoken/step.rb', line 20 def to_patch( = {}) @diffs.map { |diff| diff.to_patch() }.join("\n") end |