Class: Calibrate::Configurable::DirectoryStructure::StructurePath

Inherits:
Object
  • Object
show all
Includes:
Calibrate::Configurable
Defined in:
lib/calibrate/configurable/directory-structure.rb

Constant Summary

Constants included from Calibrate::Configurable

RequiredField

Instance Method Summary collapse

Methods included from Calibrate::Configurable

#check_required, #copy_settings, #copy_settings_to, #fail_unless_set, #field_unset?, #from_hash, #initialize_copy, #proxy_settings, #proxy_settings_to, #proxy_value, #setup_defaults, #to_hash, #unset?, unset_defaults_guard, #unset_defaults_guard

Methods included from ClassMethods

#default_value_for, #default_values, #field_metadata, #field_names, #from_hash, #included, #inspect_instance, #missing_required_fields_on, #nested, #nil_fields, #required_fields, #runtime_required_fields, #runtime_setting, #set_defaults_on, #setting, #settings, #to_hash

Constructor Details

#initialize(rel_path) ⇒ StructurePath

No #path - ambiguous whether that would be abspath or pathname



26
27
28
# File 'lib/calibrate/configurable/directory-structure.rb', line 26

def initialize(rel_path)
  self.relative_path = rel_path unless rel_path == Configurable::RequiredField
end

Instance Method Details

#inspectObject



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/calibrate/configurable/directory-structure.rb', line 45

def inspect
  "<path: #{
    if field_unset?(:absolute_path)
      if field_unset?(:relative_path)
        "<<?>>"
      else
        "?/#{relative_path}"
      end
    else
      absolute_path.inspect
    end
  }>"
end

#pathnameObject Also known as: path_name



30
31
32
33
34
35
36
37
# File 'lib/calibrate/configurable/directory-structure.rb', line 30

def pathname
  @pathname ||=
    begin
      fail_unless_set(:absolute_path)
      require 'pathname'
      Pathname.new(absolute_path)
    end
end

#to_sObject



40
41
42
43
# File 'lib/calibrate/configurable/directory-structure.rb', line 40

def to_s
  fail_unless_set(:absolute_path)
  absolute_path
end