Class: Bunch::FileNode

Inherits:
AbstractNode show all
Defined in:
lib/bunch/file_node.rb

Direct Known Subclasses

CoffeeNode, EJSNode, JadeNode, NullNode, SassNode

Instance Attribute Summary collapse

Attributes inherited from AbstractNode

#options

Instance Method Summary collapse

Methods inherited from AbstractNode

#write_to_dir, #write_to_file

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

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/bunch/file_node.rb', line 3

def name
  @name
end

#target_extensionObject

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

#contentObject



17
18
19
# File 'lib/bunch/file_node.rb', line 17

def content
  File.read(@filename)
end

#inspectObject



21
22
23
# File 'lib/bunch/file_node.rb', line 21

def inspect
  @filename.inspect
end