Class: Symbol

Inherits:
Object show all
Defined in:
lib/data_tools/symbol.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/symbol.rb', line 3

def splitkey?
  to_s =~ /:/
end

#subkeyObject

for SYMBOLS we always interpret the last part as a symbol (:“resource:id” translates to :resource => :id)



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

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

#superkeyObject

we always interpret the first part as a symbol



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

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