Class: Fixturizer::Getters::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/fixturizer/getters/init.rb

Direct Known Subclasses

Json, Yaml

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename:, options: nil) ⇒ Template

Returns a new instance of Template.



8
9
10
11
# File 'lib/fixturizer/getters/init.rb', line 8

def initialize(filename:, options: nil)
  @filename = filename
  @options = options
end

Instance Attribute Details

#data ⇒ Object (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/fixturizer/getters/init.rb', line 6

def data
  @data
end

#filename ⇒ Object (readonly)

Returns the value of attribute filename.



6
7
8
# File 'lib/fixturizer/getters/init.rb', line 6

def filename
  @filename
end

Instance Method Details

#read_file(file) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/fixturizer/getters/init.rb', line 17

def read_file(file)
    return File.readlines(file).join
rescue Errno::EACCES
  puts "Error: Permission denied to read the file #{file}."
rescue StandardError => e
  puts "Error: #{e.message}"
end

#retrieve ⇒ Object



13
14
15
# File 'lib/fixturizer/getters/init.rb', line 13

def retrieve
  raise "Abstract template, don't use"
end