Class: WritersRoom::Medium
- Inherits:
-
Object
- Object
- WritersRoom::Medium
- Defined in:
- lib/writers_room/medium.rb
Overview
Data class representing a creative writing medium type. Loaded from YAML config files in config/media/.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#scaffolded_dirs ⇒ Object
readonly
Returns the value of attribute scaffolded_dirs.
-
#specific_elements ⇒ Object
readonly
Returns the value of attribute specific_elements.
-
#statuses ⇒ Object
readonly
Returns the value of attribute statuses.
-
#universal_elements ⇒ Object
readonly
Returns the value of attribute universal_elements.
-
#workflows ⇒ Object
readonly
Returns the value of attribute workflows.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id:, label:, universal_elements: [], specific_elements: {}, scaffolded_dirs: [], workflows: [], statuses: []) ⇒ Medium
constructor
A new instance of Medium.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(id:, label:, universal_elements: [], specific_elements: {}, scaffolded_dirs: [], workflows: [], statuses: []) ⇒ Medium
Returns a new instance of Medium.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/writers_room/medium.rb', line 10 def initialize(id:, label:, universal_elements: [], specific_elements: {}, scaffolded_dirs: [], workflows: [], statuses: []) @id = id.to_sym @label = label.to_s @universal_elements = Array(universal_elements).map(&:to_sym) @specific_elements = normalize_specific_elements(specific_elements) @scaffolded_dirs = Array(scaffolded_dirs).map(&:to_s) @workflows = Array(workflows).map(&:to_sym) @statuses = Array(statuses).map(&:to_s) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/writers_room/medium.rb', line 7 def id @id end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
7 8 9 |
# File 'lib/writers_room/medium.rb', line 7 def label @label end |
#scaffolded_dirs ⇒ Object (readonly)
Returns the value of attribute scaffolded_dirs.
7 8 9 |
# File 'lib/writers_room/medium.rb', line 7 def scaffolded_dirs @scaffolded_dirs end |
#specific_elements ⇒ Object (readonly)
Returns the value of attribute specific_elements.
7 8 9 |
# File 'lib/writers_room/medium.rb', line 7 def specific_elements @specific_elements end |
#statuses ⇒ Object (readonly)
Returns the value of attribute statuses.
7 8 9 |
# File 'lib/writers_room/medium.rb', line 7 def statuses @statuses end |
#universal_elements ⇒ Object (readonly)
Returns the value of attribute universal_elements.
7 8 9 |
# File 'lib/writers_room/medium.rb', line 7 def universal_elements @universal_elements end |
#workflows ⇒ Object (readonly)
Returns the value of attribute workflows.
7 8 9 |
# File 'lib/writers_room/medium.rb', line 7 def workflows @workflows end |
Class Method Details
.from_yaml(hash) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/writers_room/medium.rb', line 21 def self.from_yaml(hash) new( id: hash["id"], label: hash["label"], universal_elements: hash["universal_elements"], specific_elements: hash["specific_elements"], scaffolded_dirs: hash["scaffolded_dirs"], workflows: hash["workflows"], statuses: hash["statuses"] ) end |
Instance Method Details
#inspect ⇒ Object
37 38 39 |
# File 'lib/writers_room/medium.rb', line 37 def inspect "#<#{self.class} id=#{id.inspect} label=#{label.inspect}>" end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/writers_room/medium.rb', line 33 def to_s label end |