Class: TentClient::TentType
- Inherits:
-
Object
- Object
- TentClient::TentType
- Defined in:
- lib/tent-client/tent_type.rb
Constant Summary collapse
- ALL =
'all'.freeze
Instance Attribute Summary collapse
-
#base ⇒ Object
Returns the value of attribute base.
-
#fragment ⇒ Object
Returns the value of attribute fragment.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #all? ⇒ Boolean
- #has_fragment? ⇒ Boolean
-
#initialize(uri = nil) ⇒ TentType
constructor
A new instance of TentType.
- #to_s(options = {}) ⇒ Object
Constructor Details
Instance Attribute Details
#base ⇒ Object
Returns the value of attribute base.
7 8 9 |
# File 'lib/tent-client/tent_type.rb', line 7 def base @base end |
#fragment ⇒ Object
Returns the value of attribute fragment.
7 8 9 |
# File 'lib/tent-client/tent_type.rb', line 7 def fragment @fragment end |
#version ⇒ Object
Returns the value of attribute version.
7 8 9 |
# File 'lib/tent-client/tent_type.rb', line 7 def version @version end |
Instance Method Details
#==(other) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/tent-client/tent_type.rb', line 41 def ==(other) unless TentType === other if String === other other = TentType.new(other) else return false end end base == other.base && version == other.version && has_fragment? == other.has_fragment? && fragment == other.fragment end |
#has_fragment? ⇒ Boolean
17 18 19 |
# File 'lib/tent-client/tent_type.rb', line 17 def has_fragment? !!@fragment_separator end |
#to_s(options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/tent-client/tent_type.rb', line 30 def to_s( = {}) return base if all? [:encode_fragment] = true unless .has_key?(:encode_fragment) if (!has_fragment? && [:fragment] != true) || [:fragment] == false "#{base}/v#{version}" else "#{base}/v#{version}##{[:encode_fragment] ? encode_fragment(fragment) : fragment}" end end |