Class: EacTemplates::Abstract::FsObject

Inherits:
Object
  • Object
show all
Defined in:
lib/eac_templates/abstract/fs_object.rb

Direct Known Subclasses

Directory, File

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.assert(obj) ⇒ EacTemplates::Abstract::FsObject, EacTemplates::Abstracts::FsObjectByPathname

Parameters:

Returns:



13
14
15
16
17
18
19
# File 'lib/eac_templates/abstract/fs_object.rb', line 13

def assert(obj)
  if obj.is_a?(self)
    obj
  else
    ::EacTemplates::Abstract::FsObjectByPathname.new(obj)
  end
end

.by_subpath(owner, parent_object, subpath, options = {}) ⇒ EacTemplates::Abstract::FsObject

Parameters:

  • owner (Object)
  • parent_object (Object, nil)
  • subpath (Pathname)

Returns:



25
26
27
28
29
30
31
32
# File 'lib/eac_templates/abstract/fs_object.rb', line 25

def by_subpath(owner, parent_object, subpath, options = {})
  r = new(owner, parent_object, nil, options)
  subpath.if_present(::Pathname.new(''), &:to_pathname).each_filename do |basename|
    parent_object = r
    r = new(owner, parent_object, basename, options)
  end
  r
end

Instance Method Details

#applierEacTemplates::Variables::Directory, EacTemplates::Variables::File



46
47
48
# File 'lib/eac_templates/abstract/fs_object.rb', line 46

def applier
  applier_class.new(self)
end

#applier_classClass

Returns:

  • (Class)


51
52
53
# File 'lib/eac_templates/abstract/fs_object.rb', line 51

def applier_class
  ::EacTemplates::Variables.const_get(type.to_s.camelize)
end

#category_moduleModule

Returns:



56
57
58
# File 'lib/eac_templates/abstract/fs_object.rb', line 56

def category_module
  self.class.module_parent
end

#path_for_searchPathname

Returns:

  • (Pathname)


61
62
63
64
65
66
67
# File 'lib/eac_templates/abstract/fs_object.rb', line 61

def path_for_search
  if parent_object.present?
    parent_object.path_for_search.join(basename)
  else
    path_for_search_prefix.join(basename)
  end
end

#path_for_search_prefixPathname

Returns:

  • (Pathname)


70
71
72
# File 'lib/eac_templates/abstract/fs_object.rb', line 70

def path_for_search_prefix
  raise_abstract_method __method__
end

#raise_not_found(message) ⇒ Object



74
75
76
# File 'lib/eac_templates/abstract/fs_object.rb', line 74

def raise_not_found(message)
  raise ::EacTemplates::Errors::NotFound, message
end

#source_setEacTemplates::Sources::Set



79
80
81
# File 'lib/eac_templates/abstract/fs_object.rb', line 79

def source_set
  options[OPTION_SOURCE_SET] || ::EacTemplates::Sources::Set.default
end

#typeSymbol

Returns:

  • (Symbol)


84
85
86
# File 'lib/eac_templates/abstract/fs_object.rb', line 84

def type
  type_list.value_validate!(self.class.name.demodulize.underscore.to_sym)
end

#type_listEacRubyUtils::Listable::SymbolList

Returns:

  • (EacRubyUtils::Listable::SymbolList)


89
90
91
# File 'lib/eac_templates/abstract/fs_object.rb', line 89

def type_list
  ::EacTemplates::Abstract::FsObject.lists.type
end