Class: Kuebiko::Preparation
- Inherits:
-
Object
- Object
- Kuebiko::Preparation
- Defined in:
- lib/kuebiko/preparation.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#scheme ⇒ Object
readonly
Returns the value of attribute scheme.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(paths, options) ⇒ Preparation
constructor
A new instance of Preparation.
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, ) @paths = paths @query = [:query] @anchor = [:anchor] @trailing_slash = [:trailing_slash] @scheme = [:scheme] @host = [:host] @port = [:port] end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
7 8 9 |
# File 'lib/kuebiko/preparation.rb', line 7 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
7 8 9 |
# File 'lib/kuebiko/preparation.rb', line 7 def port @port end |
#scheme ⇒ Object (readonly)
Returns the value of attribute scheme.
7 8 9 |
# File 'lib/kuebiko/preparation.rb', line 7 def scheme @scheme end |
Instance Method Details
#build ⇒ Object
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 |