Class: CIAT::TestElement

Inherits:
Object
  • Object
show all
Defined in:
lib/ciat/test_element.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, filename, content) ⇒ TestElement

Returns a new instance of TestElement.



7
8
9
10
11
# File 'lib/ciat/test_element.rb', line 7

def initialize(name, filename, content)
  @name = name
  @filename = filename
  @content = content
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



5
6
7
# File 'lib/ciat/test_element.rb', line 5

def filename
  @filename
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/ciat/test_element.rb', line 4

def name
  @name
end

Instance Method Details

#as_fileObject



32
33
34
35
36
37
# File 'lib/ciat/test_element.rb', line 32

def as_file
  if @content
    CIAT::Cargo.write_file(@filename, @content)
  end
  @filename
end

#contentObject



28
29
30
# File 'lib/ciat/test_element.rb', line 28

def content
  @content ||= CIAT::Cargo.read_file(@filename)
end

#describeObject



20
21
22
# File 'lib/ciat/test_element.rb', line 20

def describe
  yaml_entry["description"]
end

#templateObject



13
14
15
16
17
18
# File 'lib/ciat/test_element.rb', line 13

def template
  if yaml_entry.nil?
    raise "Need entry for #{name.to_s} in data/elements.yml"
  end
  File.join("elements", yaml_entry["template"])
end

#yaml_entryObject



24
25
26
# File 'lib/ciat/test_element.rb', line 24

def yaml_entry
  [name.to_s]
end