module DTK::DSL::Template::Parsing::ParentKey::Index
Constants
- LEFT_DELIM
- RIGHT_DELIM
Public Class Methods
parse_segment(key_seqment)
click to toggle source
returns [type, index] where index can be nil
# File lib/dsl/template/parsing/parent_key.rb, line 54 def self.parse_segment(key_seqment) type = index = nil split_on_left = key_seqment.split(LEFT_DELIM) if split_on_left.size == 1 type = key_seqment else type = split_on_left.shift # find index # being robust if index has index symbols in it by looking for leftmost left deleim and rightmost right delim rest = split_on_left.join(LEFT_DELIM) split_on_right = rest.split(RIGHT_DELIM) if split_on_right.size == 1 index = split_on_right.first else split_on_right.pop # get rid of end index = split_on_right.join(RIGHT_DELIM) end end [type, index] end
with_delims(index)
click to toggle source
# File lib/dsl/template/parsing/parent_key.rb, line 49 def self.with_delims(index) "#{LEFT_DELIM}#{index}#{RIGHT_DELIM}" end