Class: Alt::URI::Gen::AuthParts

Inherits:
Base show all
Defined in:
lib/rio/alturi/uri_parts.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#_do_esc, #_do_unesc, #nil_or

Constructor Details

#initializeAuthParts

Returns a new instance of AuthParts.



184
185
186
# File 'lib/rio/alturi/uri_parts.rb', line 184

def initialize
  @store = {}
end

Instance Attribute Details

#storeObject (readonly)

Returns the value of attribute store.



183
184
185
# File 'lib/rio/alturi/uri_parts.rb', line 183

def store
  @store
end

Class Method Details

.parse(val) ⇒ Object



191
192
193
194
195
196
197
198
199
200
201
# File 'lib/rio/alturi/uri_parts.rb', line 191

def self.parse(val)
  auth = new
  if val
    Alt::URI::Parse::RE_AUTHORITY.match(val) { |m|
      auth.store[:host] = m[2].downcase
      auth.store[:port] = m[3]
      auth.store[:userinfo] = UserInfoParts.parse(m[1])
    }
  end
  auth
end

Instance Method Details

#==(other) ⇒ Object



202
203
204
# File 'lib/rio/alturi/uri_parts.rb', line 202

def ==(other)
  @store == other.store
end

#[](sym) ⇒ Object



205
206
207
# File 'lib/rio/alturi/uri_parts.rb', line 205

def [](sym)
  @store[sym]
end

#[]=(sym, val) ⇒ Object



209
210
211
# File 'lib/rio/alturi/uri_parts.rb', line 209

def []=(sym,val)
  @store[sym] = val
end

#hostObject



216
217
218
# File 'lib/rio/alturi/uri_parts.rb', line 216

def host
  @store[:host] if @store[:host]
end

#host=(val) ⇒ Object



213
214
215
# File 'lib/rio/alturi/uri_parts.rb', line 213

def host=(val)
  @store[:host] = nil_or(val) { |v| v.downcase }
end

#initialize_copy(other) ⇒ Object



187
188
189
190
# File 'lib/rio/alturi/uri_parts.rb', line 187

def initialize_copy(other)
  super
  @store = other.store.dup
end

#passwordObject



230
231
232
# File 'lib/rio/alturi/uri_parts.rb', line 230

def password
  @store[:userinfo].password if @store[:userinfo]
end

#password=(val) ⇒ Object



226
227
228
229
# File 'lib/rio/alturi/uri_parts.rb', line 226

def password=(val)
  @store[:userinfo] ||= UserInfoParts.new
  @store[:userinfo].password = val
end

#portObject



246
247
248
# File 'lib/rio/alturi/uri_parts.rb', line 246

def port
  @store[:port]
end

#port=(val) ⇒ Object



250
251
252
# File 'lib/rio/alturi/uri_parts.rb', line 250

def port=(val)
  @store[:port] = val
end

#to_sObject



256
257
258
259
260
261
# File 'lib/rio/alturi/uri_parts.rb', line 256

def to_s
  ui = @store[:userinfo].value + '@' if @store[:userinfo] and @store[:userinfo].value
  hst = @store[:host]
  prt = ':' + @store[:port] if @store[:port]
  "#{ui}#{hst}#{prt}"
end

#userObject



223
224
225
# File 'lib/rio/alturi/uri_parts.rb', line 223

def user
  @store[:userinfo].user if @store[:userinfo]
end

#user=(val) ⇒ Object



219
220
221
222
# File 'lib/rio/alturi/uri_parts.rb', line 219

def user=(val)
  @store[:userinfo] ||= UserInfoParts.new
  @store[:userinfo].user = val
end

#userinfoObject



238
239
240
# File 'lib/rio/alturi/uri_parts.rb', line 238

def userinfo
  @store[:userinfo].value if @store[:userinfo]
end

#userinfo=(val) ⇒ Object



241
242
243
# File 'lib/rio/alturi/uri_parts.rb', line 241

def userinfo=(val)
  @store[:userinfo] = UserInfoParts.parse(val) if val
end

#valueObject



253
254
255
# File 'lib/rio/alturi/uri_parts.rb', line 253

def value
  self.to_s if self.host
end