Class: EacTemplates::Modules::Ancestor::File

Inherits:
Abstract::File show all
Includes:
FsObject
Defined in:
lib/eac_templates/modules/ancestor/file.rb

Constant Summary collapse

TEMPLATE_EXTNAME_PATTERN =
/#{::Regexp.quote(::EacTemplates::Variables::FsObject::TEMPLATE_EXTNAME)}\z/.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from FsObject

#path_for_search, #to_s

Methods inherited from Abstract::File

#content

Methods inherited from Abstract::FsObject

#applier, #applier_class, assert, by_subpath, #category_module, #path_for_search, #path_for_search_prefix, #raise_not_found, #source_set, #type, #type_list

Class Method Details

.parse_basename(basename) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/eac_templates/modules/ancestor/file.rb', line 18

def parse_basename(basename)
  basename.if_present do |v|
    v.to_pathname
      .to_path
      .gsub(TEMPLATE_EXTNAME_PATTERN, '')
      .to_pathname
  end
end

Instance Method Details

#basenamePathname

Returns:

  • (Pathname)


39
40
41
# File 'lib/eac_templates/modules/ancestor/file.rb', line 39

def basename
  self.class.parse_basename(super)
end

#found?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/eac_templates/modules/ancestor/file.rb', line 29

def found?
  source_object.found? || template?
end

#pathPathname

Returns:

  • (Pathname)


34
35
36
# File 'lib/eac_templates/modules/ancestor/file.rb', line 34

def path
  template? ? template_source_object.path : source_object.path
end

#template?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/eac_templates/modules/ancestor/file.rb', line 44

def template?
  template_source_object.found?
end