Class: Cucumber::Messages::SourceReference

Inherits:
Message
  • Object
show all
Defined in:
lib/cucumber/messages/source_reference.rb

Overview

Represents the SourceReference message in Cucumber’s message protocol.

*

Points to a [Source](#io.cucumber.messages.Source) identified by `uri` and a
[Location](#io.cucumber.messages.Location) within that file.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Message

camelize, from_json, #to_h, #to_json

Constructor Details

#initialize(uri: nil, java_method: nil, java_stack_trace_element: nil, location: nil) ⇒ SourceReference

Returns a new instance of SourceReference.



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/cucumber/messages/source_reference.rb', line 23

def initialize(
  uri: nil,
  java_method: nil,
  java_stack_trace_element: nil,
  location: nil
)
  @uri = uri
  @java_method = java_method
  @java_stack_trace_element = java_stack_trace_element
  @location = location
  super()
end

Instance Attribute Details

#java_methodObject (readonly)

Returns the value of attribute java_method.



17
18
19
# File 'lib/cucumber/messages/source_reference.rb', line 17

def java_method
  @java_method
end

#java_stack_trace_elementObject (readonly)

Returns the value of attribute java_stack_trace_element.



19
20
21
# File 'lib/cucumber/messages/source_reference.rb', line 19

def java_stack_trace_element
  @java_stack_trace_element
end

#locationObject (readonly)

Returns the value of attribute location.



21
22
23
# File 'lib/cucumber/messages/source_reference.rb', line 21

def location
  @location
end

#uriObject (readonly)

Returns the value of attribute uri.



15
16
17
# File 'lib/cucumber/messages/source_reference.rb', line 15

def uri
  @uri
end

Class Method Details

.from_h(hash) ⇒ Object

Returns a new SourceReference from the given hash. If the hash keys are camelCased, they are properly assigned to the corresponding snake_cased attributes.

Cucumber::Messages::SourceReference.from_h(some_hash) # => #<Cucumber::Messages::SourceReference:0x... ...>


43
44
45
46
47
48
49
50
51
52
# File 'lib/cucumber/messages/source_reference.rb', line 43

def self.from_h(hash)
  return nil if hash.nil?

  new(
    uri: hash[:uri],
    java_method: JavaMethod.from_h(hash[:javaMethod]),
    java_stack_trace_element: JavaStackTraceElement.from_h(hash[:javaStackTraceElement]),
    location: Location.from_h(hash[:location])
  )
end