Class: Rubysmith::Pathway

Inherits:
Struct
  • Object
show all
Defined in:
lib/rubysmith/pathway.rb

Overview

Represents a pathway which has source start and destination end.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*arguments) ⇒ Pathway

:reek:TooManyStatements



11
12
13
14
15
16
# File 'lib/rubysmith/pathway.rb', line 11

def initialize *arguments
  super
  each_pair { |key, value| self[key] = Pathname value }
  self[:start_path] = start_path.absolute? ? start_path : start_root.join(start_path)
  freeze
end

Instance Attribute Details

#end_rootObject

Returns the value of attribute end_root

Returns:

  • (Object)

    the current value of end_root



7
8
9
# File 'lib/rubysmith/pathway.rb', line 7

def end_root
  @end_root
end

#start_pathObject

Returns the value of attribute start_path

Returns:

  • (Object)

    the current value of start_path



7
8
9
# File 'lib/rubysmith/pathway.rb', line 7

def start_path
  @start_path
end

#start_rootObject

Returns the value of attribute start_root

Returns:

  • (Object)

    the current value of start_root



7
8
9
# File 'lib/rubysmith/pathway.rb', line 7

def start_root
  @start_root
end

Instance Method Details

#end_pathObject



20
# File 'lib/rubysmith/pathway.rb', line 20

def end_path = end_root.join(from_parent, start_path.basename)

#partial?Boolean

Returns:

  • (Boolean)


22
# File 'lib/rubysmith/pathway.rb', line 22

def partial? = start_path.basename.fnmatch?("_*")

#with(attributes) ⇒ Object



18
# File 'lib/rubysmith/pathway.rb', line 18

def with(attributes) = self.class.new(to_h.merge(attributes))