Class: Cucumber::Core::Ast::ExamplesTable::Row

Inherits:
Object
  • Object
show all
Includes:
DescribesItself, HasLocation
Defined in:
lib/cucumber/core/ast/examples_table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HasLocation

#all_locations, #attributes, #file, #file_colon_line, #line, #location, #multiline_arg, #tags

Methods included from DescribesItself

#describe_to

Constructor Details

#initialize(data, number, location, language, comments) ⇒ Row

Returns a new instance of Row.

Raises:

  • (ArgumentError)


69
70
71
72
73
74
75
76
# File 'lib/cucumber/core/ast/examples_table.rb', line 69

def initialize(data, number, location, language, comments)
  raise ArgumentError, data.to_s unless data.is_a?(Hash)
  @data = data
  @number = number
  @location = location
  @language = language
  @comments = comments
end

Instance Attribute Details

#commentsObject (readonly)

Returns the value of attribute comments.



67
68
69
# File 'lib/cucumber/core/ast/examples_table.rb', line 67

def comments
  @comments
end

#languageObject (readonly)

Returns the value of attribute language.



67
68
69
# File 'lib/cucumber/core/ast/examples_table.rb', line 67

def language
  @language
end

#numberObject (readonly)

Returns the value of attribute number.



67
68
69
# File 'lib/cucumber/core/ast/examples_table.rb', line 67

def number
  @number
end

Instance Method Details

#==(other) ⇒ Object



78
79
80
81
82
83
# File 'lib/cucumber/core/ast/examples_table.rb', line 78

def ==(other)
  return false unless other.class == self.class
  other.number == number &&
    other.location == location &&
    other.data == data
end

#[](parameter_name) ⇒ Object



85
86
87
# File 'lib/cucumber/core/ast/examples_table.rb', line 85

def [](parameter_name)
  @data[parameter_name]
end

#expand(string) ⇒ Object



93
94
95
96
97
98
99
# File 'lib/cucumber/core/ast/examples_table.rb', line 93

def expand(string)
  result = string.dup
  @data.each do |key, value|
    result.gsub!("<#{key}>", value.to_s)
  end
  result
end

#inspectObject



101
102
103
# File 'lib/cucumber/core/ast/examples_table.rb', line 101

def inspect
  "#<#{self.class}: #{@data.inspect} (#{location})>"
end

#valuesObject



89
90
91
# File 'lib/cucumber/core/ast/examples_table.rb', line 89

def values
  @data.values
end