Class: Cucumber::Messages::Location

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

Overview

Represents the Location message in Cucumber’s message protocol.

*

Points to a line and a column in a text 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(line: 0, column: nil) ⇒ Location

Returns a new instance of Location.



18
19
20
21
22
23
24
25
# File 'lib/cucumber/messages/location.rb', line 18

def initialize(
  line: 0,
  column: nil
)
  @line = line
  @column = column
  super()
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



16
17
18
# File 'lib/cucumber/messages/location.rb', line 16

def column
  @column
end

#lineObject (readonly)

Returns the value of attribute line.



14
15
16
# File 'lib/cucumber/messages/location.rb', line 14

def line
  @line
end

Class Method Details

.from_h(hash) ⇒ Object

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

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


34
35
36
37
38
39
40
41
# File 'lib/cucumber/messages/location.rb', line 34

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

  new(
    line: hash[:line],
    column: hash[:column]
  )
end