Class: Loca::URL::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/loca/url/parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Parser

Returns a new instance of Parser.



4
5
6
7
8
# File 'lib/loca/url/parser.rb', line 4

def initialize(url)
  @url = url
  @uri = Addressable::URI.parse(@url)
  @segments = @uri.path.split("/").reject(&:empty?)
end

Instance Method Details

#all_attrsObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/loca/url/parser.rb', line 21

def all_attrs
  {
    branch_name: @branch_name,
    pull: {
      num: @pull_num,
      url: @pull_url
    },
    remote: {
      name: @remote_name,
      url: @remote_url
    }
  }
end

#parseObject



14
15
16
17
18
19
# File 'lib/loca/url/parser.rb', line 14

def parse
  validate
  parse_attrs
  set_other_attrs
  all_attrs
end

#to_sObject



10
11
12
# File 'lib/loca/url/parser.rb', line 10

def to_s
  @url
end