Class: Cucumber::HTMLFormatter::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/html_formatter/formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(out) ⇒ Formatter

Returns a new instance of Formatter.

[View source]

12
13
14
15
16
# File 'lib/cucumber/html_formatter/formatter.rb', line 12

def initialize(out)
  @out = out
  @pre_message_written = false
  @first_message = true
end

Instance Attribute Details

#outObject (readonly)

Returns the value of attribute out.


10
11
12
# File 'lib/cucumber/html_formatter/formatter.rb', line 10

def out
  @out
end

Instance Method Details

#process_messages(messages) ⇒ Object

[View source]

18
19
20
21
22
# File 'lib/cucumber/html_formatter/formatter.rb', line 18

def process_messages(messages)
  write_pre_message
  messages.each { |message| write_message(message) }
  write_post_message
end

#write_message(message) ⇒ Object

[View source]

24
25
26
27
28
29
# File 'lib/cucumber/html_formatter/formatter.rb', line 24

def write_message(message)
  out.puts(',') unless @first_message
  out.print(message.to_json.gsub('/', '\/'))

  @first_message = false
end

#write_post_messageObject

[View source]

38
39
40
# File 'lib/cucumber/html_formatter/formatter.rb', line 38

def write_post_message
  out.print(post_message)
end

#write_pre_messageObject

[View source]

31
32
33
34
35
36
# File 'lib/cucumber/html_formatter/formatter.rb', line 31

def write_pre_message
  return if @pre_message_written

  out.puts(pre_message)
  @pre_message_written = true
end