Class: BugsBunny::Exchange

Inherits:
Object
  • Object
show all
Defined in:
lib/bugs_bunny/exchange.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(txt) ⇒ Exchange

Returns a new instance of Exchange.



10
11
12
# File 'lib/bugs_bunny/exchange.rb', line 10

def initialize(txt)
  @name, @kind, @durable, @delete, @args = txt.split("\t")
end

Instance Attribute Details

#deleteObject (readonly)

Returns the value of attribute delete.



3
4
5
# File 'lib/bugs_bunny/exchange.rb', line 3

def delete
  @delete
end

#durableObject (readonly)

Returns the value of attribute durable.



3
4
5
# File 'lib/bugs_bunny/exchange.rb', line 3

def durable
  @durable
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/bugs_bunny/exchange.rb', line 3

def name
  @name
end

Class Method Details

.parse(txt) ⇒ Object



5
6
7
8
# File 'lib/bugs_bunny/exchange.rb', line 5

def self.parse(txt)
  return nil if txt =~ /Listing|\.\.\./
  new(txt)
end

Instance Method Details

#<=>(other) ⇒ Object



14
15
16
# File 'lib/bugs_bunny/exchange.rb', line 14

def <=>(other)
  @name <=> other.name
end

#delete_xObject



27
# File 'lib/bugs_bunny/exchange.rb', line 27

def delete_x;      x(@delete);    end

#durable_xObject



26
# File 'lib/bugs_bunny/exchange.rb', line 26

def durable_x;      x(@durable);    end

#kindObject



18
19
20
# File 'lib/bugs_bunny/exchange.rb', line 18

def kind
  @kind.capitalize
end

#x(x) ⇒ Object



22
23
24
# File 'lib/bugs_bunny/exchange.rb', line 22

def x(x)
  eval(x) ? "    X" : ""
end