Sha256: 7ec114016f7af0dcb761fac611eb4d8c6e23ac4b19eee7e2c70308acf2768882
Contents?: true
Size: 397 Bytes
Versions: 3
Compression:
Stored size: 397 Bytes
Contents
module Restruct class Id < String attr_reader :separator def self.[](id) new id end def initialize(id, separator=nil) @separator = separator || Restruct.id_separator super id.to_s end def [](id) Id.new "#{to_s}#{separator}#{id}", separator end def sections split(separator).map { |s| Id.new s, separator } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
restruct-1.1.0 | lib/restruct/id.rb |
restruct-1.0.0 | lib/restruct/id.rb |
restruct-0.2.0 | lib/restruct/id.rb |