Class: Bunch::FileNode
- Inherits:
-
AbstractNode
- Object
- AbstractNode
- Bunch::FileNode
- Defined in:
- lib/bunch/file_node.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#target_extension ⇒ Object
Returns the value of attribute target_extension.
Attributes inherited from AbstractNode
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(fn) ⇒ FileNode
constructor
A new instance of FileNode.
- #inspect ⇒ Object
Methods inherited from AbstractNode
Constructor Details
#initialize(fn) ⇒ FileNode
Returns a new instance of FileNode.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/bunch/file_node.rb', line 5 def initialize(fn) @filename = fn if fn =~ /\.[^.]*$/ @name = File.basename($`) @target_extension = $& else @name = File.basename(@filename) @target_extension = nil end end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/bunch/file_node.rb', line 3 def name @name end |
#target_extension ⇒ Object
Returns the value of attribute target_extension.
3 4 5 |
# File 'lib/bunch/file_node.rb', line 3 def target_extension @target_extension end |
Instance Method Details
#content ⇒ Object
17 18 19 |
# File 'lib/bunch/file_node.rb', line 17 def content File.read(@filename) end |
#inspect ⇒ Object
21 22 23 |
# File 'lib/bunch/file_node.rb', line 21 def inspect @filename.inspect end |