Class: Kuebiko::Preparation

Inherits:
Object
  • Object
show all
Defined in:
lib/kuebiko/preparation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(paths, options) ⇒ Preparation

Returns a new instance of Preparation.



9
10
11
12
13
14
15
16
17
# File 'lib/kuebiko/preparation.rb', line 9

def initialize(paths, options)
  @paths = paths
  @query = options[:query]
  @anchor = options[:anchor]
  @trailing_slash = options[:trailing_slash]
  @scheme = options[:scheme]
  @host = options[:host]
  @port = options[:port]
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



7
8
9
# File 'lib/kuebiko/preparation.rb', line 7

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



7
8
9
# File 'lib/kuebiko/preparation.rb', line 7

def port
  @port
end

#schemeObject (readonly)

Returns the value of attribute scheme.



7
8
9
# File 'lib/kuebiko/preparation.rb', line 7

def scheme
  @scheme
end

Instance Method Details

#buildObject



19
20
21
22
23
24
25
# File 'lib/kuebiko/preparation.rb', line 19

def build
  path = @paths.select{|item| item.present?}.map{|item| CGI.escape(item.to_s)}.join('/')
  path << "/" if path.present? && @trailing_slash
  path << "?#{@query.to_query}" if @query.present?
  path << "##{CGI.escape(@anchor.to_s)}" if @anchor.present?
  path
end