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
Constants included from Token
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes included from Expression
Instance Method Summary collapse
- #expand(vars) ⇒ Object
-
#initialize(name) ⇒ Variable
constructor
A new instance of Variable.
- #to_r ⇒ Object
- #to_s ⇒ Object
Methods included from Expression
Methods included from Token
#ends_with_slash?, #expand_partial, #host?, #scheme?, #size, #starts_with_slash?, #variables
Constructor Details
#initialize(name) ⇒ Variable
Returns a new instance of Variable.
77 78 79 80 |
# File 'lib/uri_template/colon.rb', line 77 def initialize(name) @name = name @variables = [name] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
75 76 77 |
# File 'lib/uri_template/colon.rb', line 75 def name @name end |
Instance Method Details
#expand(vars) ⇒ Object
82 83 84 |
# File 'lib/uri_template/colon.rb', line 82 def (vars) return Utils.escape_url(Utils.object_to_param(vars[name])) end |
#to_r ⇒ Object
86 87 88 |
# File 'lib/uri_template/colon.rb', line 86 def to_r return '([^/]*?)' end |
#to_s ⇒ Object
90 91 92 |
# File 'lib/uri_template/colon.rb', line 90 def to_s return ":#{name}" end |