Class: Ryo::Target
- Inherits:
-
Object
- Object
- Ryo::Target
- Defined in:
- lib/ryo/target.rb
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #fld ⇒ Object
-
#initialize(uri) ⇒ Target
constructor
A new instance of Target.
- #ip ⇒ Object
Constructor Details
#initialize(uri) ⇒ Target
Returns a new instance of Target.
8 9 10 11 |
# File 'lib/ryo/target.rb', line 8 def initialize(uri) @uri = URI.parse(uri) @domain = @uri.host end |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
7 8 9 |
# File 'lib/ryo/target.rb', line 7 def domain @domain end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
7 8 9 |
# File 'lib/ryo/target.rb', line 7 def uri @uri end |
Instance Method Details
#fld ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ryo/target.rb', line 13 def fld @fld ||= String.new.tap do |out| removed_tlds_domain = domain.gsub(tlds_regexp, "") # test.com => ["test"] # dev.test.com => ["dev", "test"] parts = removed_tlds_domain.split(".") if parts.length == 1 || ip? out << domain else idx = domain.split(".").index(parts.last) out << domain.split(".")[idx..-1].join(".") end end end |