Class: Gherkin::Formatter::Argument
- Inherits:
-
Object
- Object
- Gherkin::Formatter::Argument
- Defined in:
- lib/gherkin/formatter/argument.rb
Instance Attribute Summary collapse
-
#byte_offset ⇒ Object
readonly
Returns the value of attribute byte_offset.
-
#val ⇒ Object
readonly
Returns the value of attribute val.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(byte_offset, val) ⇒ Argument
constructor
A new instance of Argument.
Constructor Details
#initialize(byte_offset, val) ⇒ Argument
Returns a new instance of Argument.
9 10 11 |
# File 'lib/gherkin/formatter/argument.rb', line 9 def initialize(byte_offset, val) @byte_offset, @val = byte_offset, val end |
Instance Attribute Details
#byte_offset ⇒ Object (readonly)
Returns the value of attribute byte_offset.
7 8 9 |
# File 'lib/gherkin/formatter/argument.rb', line 7 def byte_offset @byte_offset end |
#val ⇒ Object (readonly)
Returns the value of attribute val.
7 8 9 |
# File 'lib/gherkin/formatter/argument.rb', line 7 def val @val end |
Class Method Details
.format(string, argument_format, arguments) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/gherkin/formatter/argument.rb', line 13 def self.format(string, argument_format, arguments) arguments ||= [] s = string.dup offset = past_offset = 0 arguments.each do |arg| next if arg.byte_offset.nil? || arg.byte_offset < past_offset replacement = argument_format.format_argument(arg.val) s[arg.byte_offset + offset, arg.val.length] = replacement offset += replacement.unpack("U*").length - arg.val.unpack("U*").length past_offset = arg.byte_offset + arg.val.length end s end |