Class: Classifile::State
- Inherits:
-
Object
- Object
- Classifile::State
- Includes:
- AssertChecker, ExtensionChecker, NameChecker
- Defined in:
- lib/classifile/state.rb
Overview
Class that manages the current state. The DSL code will be executed on an instance of this class A State is created for each dir and group.
Instance Attribute Summary collapse
-
#additional_filename ⇒ Object
Returns the value of attribute additional_filename.
-
#after_save_syms ⇒ Object
Returns the value of attribute after_save_syms.
-
#empty ⇒ Object
(also: #empty?)
Returns the value of attribute empty.
-
#file ⇒ Object
Returns the value of attribute file.
-
#gotcha ⇒ Object
readonly
Returns the value of attribute gotcha.
-
#save_name ⇒ Object
Returns the value of attribute save_name.
-
#to_path ⇒ Object
Returns the value of attribute to_path.
Attributes included from NameChecker
Attributes included from ExtensionChecker
Instance Method Summary collapse
- #after_save(method_name) ⇒ Object
- #del(&block) ⇒ Object
- #dir(dir_name, &block) ⇒ Object
- #empty_dir! ⇒ Object
- #group(_group_name = "", &block) ⇒ Object
-
#initialize(file) ⇒ State
constructor
A new instance of State.
Methods included from NameChecker
Methods included from ExtensionChecker
Methods included from AssertChecker
#method_missing, #respond_to_missing?
Constructor Details
#initialize(file) ⇒ State
Returns a new instance of State.
23 24 25 26 27 28 29 30 |
# File 'lib/classifile/state.rb', line 23 def initialize(file) @file = file @empty = false @extname = @file.extname @name = @file.basename @gotcha = nil super() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Classifile::AssertChecker
Instance Attribute Details
#additional_filename ⇒ Object
Returns the value of attribute additional_filename.
14 15 16 |
# File 'lib/classifile/state.rb', line 14 def additional_filename @additional_filename end |
#after_save_syms ⇒ Object
Returns the value of attribute after_save_syms.
14 15 16 |
# File 'lib/classifile/state.rb', line 14 def after_save_syms @after_save_syms end |
#empty ⇒ Object Also known as: empty?
Returns the value of attribute empty.
14 15 16 |
# File 'lib/classifile/state.rb', line 14 def empty @empty end |
#file ⇒ Object
Returns the value of attribute file.
14 15 16 |
# File 'lib/classifile/state.rb', line 14 def file @file end |
#gotcha ⇒ Object (readonly)
Returns the value of attribute gotcha.
20 21 22 |
# File 'lib/classifile/state.rb', line 20 def gotcha @gotcha end |
#save_name ⇒ Object
Returns the value of attribute save_name.
14 15 16 |
# File 'lib/classifile/state.rb', line 14 def save_name @save_name end |
#to_path ⇒ Object
Returns the value of attribute to_path.
14 15 16 |
# File 'lib/classifile/state.rb', line 14 def to_path @to_path end |
Instance Method Details
#after_save(method_name) ⇒ Object
66 67 68 |
# File 'lib/classifile/state.rb', line 66 def after_save(method_name) @after_save_syms << method_name end |
#del(&block) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/classifile/state.rb', line 52 def del(&block) return if @gotcha child = make_child "" child_run!(child, block) do @gotcha = RemoveFile.new(File.(@file.full_path)) sets_after_save_proc(child) end end |
#dir(dir_name, &block) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/classifile/state.rb', line 32 def dir(dir_name, &block) return if @gotcha child = make_child dir_name child_run!(child, block) do @gotcha = MoveFile.new(File.(@file.full_path), File.(File.join(child.to_path, child.save_name))) sets_after_save_proc(child) end end |
#empty_dir! ⇒ Object
62 63 64 |
# File 'lib/classifile/state.rb', line 62 def empty_dir! @empty = true end |
#group(_group_name = "", &block) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/classifile/state.rb', line 43 def group(_group_name = "", &block) return if @gotcha child = make_child "" child_run!(child, block) do # Ignored end end |