Module: Cardiac::UriMethods

Included in:
Resource
Defined in:
lib/cardiac/resource/uri_methods.rb

Instance Method Summary collapse

Instance Method Details

#at(rel) ⇒ Object

Relative resource selection.



49
50
51
52
# File 'lib/cardiac/resource/uri_methods.rb', line 49

def at(rel)
  apply_uri_components! check_at(rel) if rel.present?
  self
end

#host(s) ⇒ Object

Host and port selection.



37
# File 'lib/cardiac/resource/uri_methods.rb', line 37

def host(s) self.host_value = s ; self end

#httpObject



9
# File 'lib/cardiac/resource/uri_methods.rb', line 9

def http()  ssl(false) end

#http_method(k) ⇒ Object

HTTP method selection.



21
# File 'lib/cardiac/resource/uri_methods.rb', line 21

def http_method(k) self.method_value = k.to_s.downcase.to_sym ; self end

#httpsObject



10
# File 'lib/cardiac/resource/uri_methods.rb', line 10

def https() ssl(true)  end

#password(s) ⇒ Object



25
# File 'lib/cardiac/resource/uri_methods.rb', line 25

def password(s) self.password_value = s ; self end

#path(s, *rest) ⇒ Object

Path selection.



42
# File 'lib/cardiac/resource/uri_methods.rb', line 42

def path(s,*rest) self.path_values += check_paths(rest.unshift(s)) ; self end

#port(n) ⇒ Object



39
# File 'lib/cardiac/resource/uri_methods.rb', line 39

def port(n) self.port_value = n ; self end

#query(q, *rest) ⇒ Object

Query parameter selection.



45
# File 'lib/cardiac/resource/uri_methods.rb', line 45

def query(q,*rest) self.query_values += check_queries(rest.unshift(q)) ; self end

#reset_query(*q) ⇒ Object



46
# File 'lib/cardiac/resource/uri_methods.rb', line 46

def reset_query(*q) query_values.replace check_queries(q) ; self end

#scheme(word) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/cardiac/resource/uri_methods.rb', line 11

def scheme(word)
  case word
  when /^http$/i then http
  when /^https$/i then https
  when NilClass then ssl(nil)
  else raise ArgumentError
  end
end

#ssl(z) ⇒ Object

Scheme selection.



8
# File 'lib/cardiac/resource/uri_methods.rb', line 8

def ssl(z)  self.https_value = z.nil? ? z : !!z; self end

#to_relative_uriObject

Convert this resource into a relative URI.



65
66
67
# File 'lib/cardiac/resource/uri_methods.rb', line 65

def to_relative_uri
  build_uri.route_from base_value
end

#to_relative_urlObject

Convert this resource into a relative URL string



70
71
72
# File 'lib/cardiac/resource/uri_methods.rb', line 70

def to_relative_url
  to_relative_uri.to_s
end

#to_uriObject

Convert this resource into a URI.



55
56
57
# File 'lib/cardiac/resource/uri_methods.rb', line 55

def to_uri
  build_uri
end

#to_urlObject

Convert this resource into an URL string.



60
61
62
# File 'lib/cardiac/resource/uri_methods.rb', line 60

def to_url
  to_uri.to_s
end

#user(s) ⇒ Object

Userinfo selection.



24
# File 'lib/cardiac/resource/uri_methods.rb', line 24

def user(s) self.user_value = s ; self end

#userinfo(userinfo) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/cardiac/resource/uri_methods.rb', line 26

def userinfo(userinfo)
  if userinfo
    self.user_value, _password = userinfo.split(':',2)
    self.password_value ||= _password
  else
    self.user_value = self.password_value = nil
  end
  self
end