Class: PathBuilder

Inherits:
Struct
  • Object
show all
Defined in:
lib/src/extractor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#baseObject

Returns the value of attribute base

Returns:

  • (Object)

    the current value of base



7
8
9
# File 'lib/src/extractor.rb', line 7

def base
  @base
end

#parentObject

Returns the value of attribute parent

Returns:

  • (Object)

    the current value of parent



7
8
9
# File 'lib/src/extractor.rb', line 7

def parent
  @parent
end

#tagObject

Returns the value of attribute tag

Returns:

  • (Object)

    the current value of tag



7
8
9
# File 'lib/src/extractor.rb', line 7

def tag
  @tag
end

Instance Method Details

#buildObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/src/extractor.rb', line 8

def build
  paths = relative_path.split("/").then do |paths|
    if parent.present?
      navigate_to_parent(parent, paths)
    else
      paths
    end
  end

  paths << tag unless tag.is_a? Array
  full_path = paths.flatten.compact.join("/")
  "//#{full_path}"
end