Class: TentD::TentType

Inherits:
Object
  • Object
show all
Defined in:
lib/tentd/tent_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri = nil) ⇒ TentType

Returns a new instance of TentType.



5
6
7
8
9
10
11
12
# File 'lib/tentd/tent_type.rb', line 5

def initialize(uri = nil)
  if uri
    @version = TentVersion.from_uri(uri)
    view_split = uri.to_s.split('#')
    @view = view_split[1]
    @base = view_split[0].to_s.sub(%r{/v[^a-z/][^/]*$}, '')
  end
end

Instance Attribute Details

#baseObject

Returns the value of attribute base.



3
4
5
# File 'lib/tentd/tent_type.rb', line 3

def base
  @base
end

#versionObject

Returns the value of attribute version.



3
4
5
# File 'lib/tentd/tent_type.rb', line 3

def version
  @version
end

#viewObject

Returns the value of attribute view.



3
4
5
# File 'lib/tentd/tent_type.rb', line 3

def view
  @view
end

Instance Method Details

#uriObject



14
15
16
17
18
# File 'lib/tentd/tent_type.rb', line 14

def uri
  version_part = @version.nil? ? '' : "/v#{@version}"
  view_part = @view.nil? ? '' : "##{@view}"
  "#{@base}#{version_part}#{view_part}"
end