Method: LaunchDarkly::Reference#component
- Defined in:
- lib/ldclient-rb/reference.rb
#component(index) ⇒ Symbol?
Retrieves a single path component from the attribute reference.
For a simple attribute reference such as “name” with no leading slash, if index is zero, #component returns the attribute name as a symbol.
For an attribute reference with a leading slash, if index is non-negative and less than #depth, Component returns the path component as a symbol.
If index is out of range, it returns nil.
Reference.create(“a”).component(0) # returns “a” Reference.create(“/a/b”).component(1) # returns “b”
226 227 228 229 230 |
# File 'lib/ldclient-rb/reference.rb', line 226 def component(index) return nil if index < 0 || index >= depth @components[index] end |