class Kuebiko::Url
Constants
- COMPONENTS
- DEFAULT
Public Class Methods
default_components(options = {})
click to toggle source
# File lib/kuebiko/url/components.rb, line 10 def default_components(options = {}) options.each do |comp, value| raise ArgumentError, "unknown components #{comp.inspect}" unless COMPONENTS.include?(comp) instance_eval "#{comp}(value)" end end
material(*names)
click to toggle source
# File lib/kuebiko/url/material.rb, line 4 def material(*names) class_eval <<-DEF_INIT, __FILE__, __LINE__ + 1 def initialize(*materials, **options) #{names.map{|n| "@_#{n}"}.join(", ")}, _dust = materials @_options = options end #{names.map{|n| "def #{n}; @_#{n}; end"}.join("\n")} private #{names.map{|n| ":#{n}"}.join(", ")} DEF_INIT end
method_added(name)
click to toggle source
# File lib/kuebiko/url.rb, line 7 def self.method_added(name) return unless public_method_defined?(name) return if /_(path|url)\z/ === name class_eval <<-DEF_URL_METHOD, __FILE__, __LINE__ + 1 class << self def #{name}_path(*args, **options) new(*args, **options).#{name}_path end def #{name}_url(*args, **options) new(*args, **options).#{name}_url end end def #{name}_path(options = {}) "/" + #{name}.build end def #{name}_url(options = {}) url = my_scheme.to_s + "://" + my_host.to_s url << (":" + my_port.to_s) if my_port url + "/" + #{name}.build end DEF_URL_METHOD end
new(*_, **options)
click to toggle source
# File lib/kuebiko/url.rb, line 34 def initialize(*_, **options) @_options = options end
Private Instance Methods
build(*paths, **options)
click to toggle source
# File lib/kuebiko/url.rb, line 40 def build(*paths, **options) options[:trailing_slash] ||= my_trailing_slash Preparation.new(paths, options) end
options()
click to toggle source
# File lib/kuebiko/url.rb, line 45 def options @_options end