Class: Siren::Stack

Inherits:
Object
  • Object
show all
Defined in:
lib/siren/stack.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStack

Returns a new instance of Stack.



13
14
15
# File 'lib/siren/stack.rb', line 13

def initialize ()
  @things = []
end

Instance Attribute Details

#thingsObject (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_yamlObject



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