Class: Bunch::AbstractNode

Inherits:
Object
  • Object
show all
Defined in:
lib/bunch/abstract_node.rb

Direct Known Subclasses

DirectoryNode, FileNode

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#contentObject Also known as: name, target_extension

Raises:

  • (NotImplementedError)


5
6
7
# File 'lib/bunch/abstract_node.rb', line 5

def content
  raise NotImplementedError
end

#write_to_dir(dir) ⇒ Object



11
12
13
# File 'lib/bunch/abstract_node.rb', line 11

def write_to_dir(dir)
  write_to_file(File.join(dir, name))
end

#write_to_file(fn) ⇒ Object



15
16
17
18
# File 'lib/bunch/abstract_node.rb', line 15

def write_to_file(fn)
  out_file = "#{fn}#{target_extension}"
  File.open(out_file, 'w') { |f| f.write(content) }
end