Class: String

Inherits:
Object show all
Defined in:
lib/data_tools/string.rb

Instance Method Summary collapse

Instance Method Details

#splitkey?Boolean

identifying keys (strings) that represent hierarchical structures, with format “superkey:subkey”

Returns:

  • (Boolean)


3
4
5
# File 'lib/data_tools/string.rb', line 3

def splitkey?
  self =~ /:/
end

#subkeyObject

for STRINGS we always interpret the last part as a string (“resource:name” translates to :resource => name)



11
12
13
# File 'lib/data_tools/string.rb', line 11

def subkey
  split(/:/, 2).last
end

#superkeyObject

we always interpret the first part as a symbol



7
8
9
# File 'lib/data_tools/string.rb', line 7

def superkey
  split(/:/, 2).first.to_sym
end