Class: Snaptoken::Step

Inherits:
Object
  • Object
show all
Defined in:
lib/snaptoken/step.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#diffsObject

Returns the value of attribute diffs.



2
3
4
# File 'lib/snaptoken/step.rb', line 2

def diffs
  @diffs
end

#numberObject

Returns the value of attribute number.



2
3
4
# File 'lib/snaptoken/step.rb', line 2

def number
  @number
end

#summaryObject

Returns the value of attribute summary.



2
3
4
# File 'lib/snaptoken/step.rb', line 2

def summary
  @summary
end

#textObject

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(options = {})
  @diffs.map { |diff| diff.to_patch(options) }.join("\n")
end