Class: Kriterion::Standard
Constant Summary collapse
- @@standards =
[]
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#description ⇒ Object
Returns the value of attribute description.
-
#item_syntax ⇒ Object
Returns the value of attribute item_syntax.
-
#items ⇒ Object
Returns the value of attribute items.
-
#name ⇒ Object
Returns the value of attribute name.
-
#section_separator ⇒ Object
Returns the value of attribute section_separator.
-
#sections ⇒ Object
Returns the value of attribute sections.
-
#title ⇒ Object
Returns the value of attribute title.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #compliance ⇒ Object
- #expandable? ⇒ Boolean
- #expandable_keys ⇒ Object
-
#initialize(data) ⇒ Standard
constructor
A new instance of Standard.
- #type ⇒ Object
Methods inherited from Object
#find_section, #flush_compliance!, #full_keys, #primary_key, primary_key, #to_h
Constructor Details
#initialize(data) ⇒ Standard
Returns a new instance of Standard.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/kriterion/standard.rb', line 19 def initialize(data) super(data) @uuid = data['uuid'] || SecureRandom.uuid @name = data['name'] @date = data['date'] @description = data['description'] @title = data['title'] @version = data['version'] @item_syntax = if data['item_syntax'].is_a? Regexp data['item_syntax'] else Regexp.new(data['item_syntax']) end @section_separator = data['section_separator'] @sections = data['sections'] || [] @items = data['items'] || [] end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
10 11 12 |
# File 'lib/kriterion/standard.rb', line 10 def date @date end |
#description ⇒ Object
Returns the value of attribute description.
11 12 13 |
# File 'lib/kriterion/standard.rb', line 11 def description @description end |
#item_syntax ⇒ Object
Returns the value of attribute item_syntax.
14 15 16 |
# File 'lib/kriterion/standard.rb', line 14 def item_syntax @item_syntax end |
#items ⇒ Object
Returns the value of attribute items.
17 18 19 |
# File 'lib/kriterion/standard.rb', line 17 def items @items end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/kriterion/standard.rb', line 9 def name @name end |
#section_separator ⇒ Object
Returns the value of attribute section_separator.
15 16 17 |
# File 'lib/kriterion/standard.rb', line 15 def section_separator @section_separator end |
#sections ⇒ Object
Returns the value of attribute sections.
16 17 18 |
# File 'lib/kriterion/standard.rb', line 16 def sections @sections end |
#title ⇒ Object
Returns the value of attribute title.
12 13 14 |
# File 'lib/kriterion/standard.rb', line 12 def title @title end |
#uuid ⇒ Object
Returns the value of attribute uuid.
8 9 10 |
# File 'lib/kriterion/standard.rb', line 8 def uuid @uuid end |
#version ⇒ Object
Returns the value of attribute version.
13 14 15 |
# File 'lib/kriterion/standard.rb', line 13 def version @version end |
Class Method Details
.get(name) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/kriterion/standard.rb', line 37 def self.get(name) # Reload all standards Kriterion::Standard.reload_all! results = @@standards.select { |s| s.name == name } case results.length when 0 raise "No standards found with name: #{name}" when 1 results.first else raise "Multiple standards found with #{name}" end end |
Instance Method Details
#compliance ⇒ Object
73 74 75 |
# File 'lib/kriterion/standard.rb', line 73 def compliance super([items, sections].flatten) end |
#expandable? ⇒ Boolean
58 59 60 |
# File 'lib/kriterion/standard.rb', line 58 def true end |
#expandable_keys ⇒ Object
62 63 64 65 66 67 |
# File 'lib/kriterion/standard.rb', line 62 def %i[ sections items ] end |
#type ⇒ Object
69 70 71 |
# File 'lib/kriterion/standard.rb', line 69 def type :standard end |