Class: MarkdownComposer::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/markdown_composer/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output:, buffer:, markdown:, html:, diagnostics:, errors:, stages: {}) ⇒ Result

Returns a new instance of Result.



7
8
9
10
11
12
13
14
15
# File 'lib/markdown_composer/result.rb', line 7

def initialize(output:, buffer:, markdown:, html:, diagnostics:, errors:, stages: {})
  @output = output
  @buffer = buffer
  @markdown = markdown
  @html = html
  @diagnostics = diagnostics
  @errors = errors
  @stages = stages
end

Instance Attribute Details

#bufferObject (readonly)

Returns the value of attribute buffer.



5
6
7
# File 'lib/markdown_composer/result.rb', line 5

def buffer
  @buffer
end

#diagnosticsObject (readonly)

Returns the value of attribute diagnostics.



5
6
7
# File 'lib/markdown_composer/result.rb', line 5

def diagnostics
  @diagnostics
end

#errorsObject (readonly)

Returns the value of attribute errors.



5
6
7
# File 'lib/markdown_composer/result.rb', line 5

def errors
  @errors
end

#htmlObject (readonly)

Returns the value of attribute html.



5
6
7
# File 'lib/markdown_composer/result.rb', line 5

def html
  @html
end

#markdownObject (readonly)

Returns the value of attribute markdown.



5
6
7
# File 'lib/markdown_composer/result.rb', line 5

def markdown
  @markdown
end

#outputObject (readonly)

Returns the value of attribute output.



5
6
7
# File 'lib/markdown_composer/result.rb', line 5

def output
  @output
end

#stagesObject (readonly)

Returns the value of attribute stages.



5
6
7
# File 'lib/markdown_composer/result.rb', line 5

def stages
  @stages
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/markdown_composer/result.rb', line 17

def success?
  errors.empty?
end

#to_hObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/markdown_composer/result.rb', line 21

def to_h
  {
    success: success?,
    output: output,
    buffer: buffer&.to_h,
    markdown: markdown,
    html: html,
    diagnostics: diagnostics.map(&:to_h),
    errors: errors.map(&:to_h),
    stages: stages
  }
end