Class: Restruct::Id
- Inherits:
-
String
- Object
- String
- Restruct::Id
- Defined in:
- lib/restruct/id.rb
Instance Attribute Summary collapse
-
#separator ⇒ Object
readonly
Returns the value of attribute separator.
Class Method Summary collapse
Instance Method Summary collapse
- #[](id) ⇒ Object
-
#initialize(id, separator = nil) ⇒ Id
constructor
A new instance of Id.
- #sections ⇒ Object
Constructor Details
#initialize(id, separator = nil) ⇒ Id
10 11 12 13 |
# File 'lib/restruct/id.rb', line 10 def initialize(id, separator=nil) @separator = separator || Restruct.id_separator super id.to_s end |
Instance Attribute Details
#separator ⇒ Object (readonly)
Returns the value of attribute separator.
4 5 6 |
# File 'lib/restruct/id.rb', line 4 def separator @separator end |
Class Method Details
.[](id) ⇒ Object
6 7 8 |
# File 'lib/restruct/id.rb', line 6 def self.[](id) new id end |
Instance Method Details
#[](id) ⇒ Object
15 16 17 |
# File 'lib/restruct/id.rb', line 15 def [](id) Id.new "#{to_s}#{separator}#{id}", separator end |
#sections ⇒ Object
19 20 21 |
# File 'lib/restruct/id.rb', line 19 def sections split(separator).map { |s| Id.new s, separator } end |