Class: CIAT::TestElement
- Inherits:
-
Object
- Object
- CIAT::TestElement
- Defined in:
- lib/ciat/test_element.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #as_file ⇒ Object
- #content ⇒ Object
- #describe ⇒ Object
-
#initialize(name, filename, content) ⇒ TestElement
constructor
A new instance of TestElement.
- #template ⇒ Object
- #yaml_entry ⇒ Object
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
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
5 6 7 |
# File 'lib/ciat/test_element.rb', line 5 def filename @filename end |
#name ⇒ Object (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_file ⇒ Object
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 |
#content ⇒ Object
28 29 30 |
# File 'lib/ciat/test_element.rb', line 28 def content @content ||= CIAT::Cargo.read_file(@filename) end |
#describe ⇒ Object
20 21 22 |
# File 'lib/ciat/test_element.rb', line 20 def describe yaml_entry["description"] end |
#template ⇒ Object
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_entry ⇒ Object
24 25 26 |
# File 'lib/ciat/test_element.rb', line 24 def yaml_entry [name.to_s] end |