Class: Siren::Stack
- Inherits:
-
Object
- Object
- Siren::Stack
- Defined in:
- lib/siren/stack.rb
Instance Attribute Summary collapse
-
#things ⇒ Object
readonly
Returns the value of attribute things.
Class Method Summary collapse
Instance Method Summary collapse
- #<<(thing) ⇒ Object
-
#initialize ⇒ Stack
constructor
A new instance of Stack.
- #to_yaml ⇒ Object
Constructor Details
#initialize ⇒ Stack
Returns a new instance of Stack.
13 14 15 |
# File 'lib/siren/stack.rb', line 13 def initialize () @things = [] end |
Instance Attribute Details
#things ⇒ Object (readonly)
Returns the value of attribute things.
7 8 9 |
# File 'lib/siren/stack.rb', line 7 def things @things end |
Class Method Details
.load(filename) ⇒ Object
9 10 11 |
# File 'lib/siren/stack.rb', line 9 def self.load (filename) new(YAML.load(File.read(filename))) end |
Instance Method Details
#<<(thing) ⇒ Object
17 18 19 |
# File 'lib/siren/stack.rb', line 17 def << (thing) @things << thing end |
#to_yaml ⇒ Object
21 22 23 24 25 |
# File 'lib/siren/stack.rb', line 21 def to_yaml () @things.uniq.map do |thing| JSON.parse(thing.deep_compact.to_json).to_yaml end.join end |