Class: Latte::Address
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.default ⇒ Object
3 4 5 |
# File 'lib/latte/address.rb', line 3 def self.default @default ||= new end |
Instance Method Details
#ip_address ⇒ Object
15 16 17 18 |
# File 'lib/latte/address.rb', line 15 def ip_address matches = string.scan /(\d+\.\d+\.\d+\.\d+)/ return matches[0][0] unless matches[0].nil? end |
#port ⇒ Object
21 22 23 24 |
# File 'lib/latte/address.rb', line 21 def port matches = string.scan /:(\d+)$/ return matches[0][0].to_i unless matches[0].nil? end |
#protocol ⇒ Object
9 10 11 12 |
# File 'lib/latte/address.rb', line 9 def protocol matches = string.scan /^(udp|tcp):\/\// return matches[0][0] unless matches[0].nil? end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/latte/address.rb', line 32 def to_s "#{protocol}://#{ip_address}:#{port}" end |