Class: URITemplate::Colon::Token::Variable
- Inherits:
-
URITemplate::Colon::Token
- Object
- URITemplate::Colon::Token
- URITemplate::Colon::Token::Variable
- Includes:
- Expression
- Defined in:
- lib/uri_template/colon.rb
Direct Known Subclasses
Constant Summary
Constant Summary
Constants included from Token
Instance Attribute Summary (collapse)
-
- (Object) name
readonly
Returns the value of attribute name.
Attributes included from Expression
Instance Method Summary (collapse)
- - (Object) expand(vars)
-
- (Variable) initialize(name)
constructor
A new instance of Variable.
- - (Object) to_r
- - (Object) to_s
Methods included from Expression
Methods included from Token
#ends_with_slash?, #host?, #scheme?, #size, #starts_with_slash?, #variables
Constructor Details
- (Variable) initialize(name)
A new instance of Variable
71 72 73 74 |
# File 'lib/uri_template/colon.rb', line 71 def initialize(name) @name = name @variables = [name] end |
Instance Attribute Details
- (Object) name (readonly)
Returns the value of attribute name
69 70 71 |
# File 'lib/uri_template/colon.rb', line 69 def name @name end |
Instance Method Details
- (Object) expand(vars)
76 77 78 |
# File 'lib/uri_template/colon.rb', line 76 def (vars) return Utils.escape_url(Utils.object_to_param(vars[name])) end |
- (Object) to_r
80 81 82 |
# File 'lib/uri_template/colon.rb', line 80 def to_r return '([^/]*?)' end |
- (Object) to_s
84 85 86 |
# File 'lib/uri_template/colon.rb', line 84 def to_s return ":#{name}" end |