Class: Onion::RouterList
- Inherits:
-
Object
- Object
- Onion::RouterList
- Defined in:
- lib/onion/elements/router_list.rb
Overview
Onion::RouterList is a list of Onion::Router objects.
Instance Attribute Summary collapse
-
#routers ⇒ Object
readonly
Returns the value of attribute routers.
Instance Method Summary collapse
-
#exits ⇒ Object
Returns the routers that are exit routers.
-
#guards ⇒ Object
Returns the routers that are guard routers.
-
#initialize(text) ⇒ RouterList
constructor
A new instance of RouterList.
-
#middlemen ⇒ Object
Returns the routers that are neither guard or exit routers.
Constructor Details
#initialize(text) ⇒ RouterList
Returns a new instance of RouterList.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/onion/elements/router_list.rb', line 5 def initialize(text) if text.blank? @routers = [] return self end parser = Onion::RouterStatusesParser.new if nodes = parser.parse(text) @routers = nodes.routers else raise Exception, "Couldn't parse #{text} b/c #{parser.failure_reason}." end end |
Instance Attribute Details
#routers ⇒ Object (readonly)
Returns the value of attribute routers.
4 5 6 |
# File 'lib/onion/elements/router_list.rb', line 4 def routers @routers end |
Instance Method Details
#exits ⇒ Object
Returns the routers that are exit routers.
24 25 26 |
# File 'lib/onion/elements/router_list.rb', line 24 def exits @routers.select { |r| r.exit? } end |
#guards ⇒ Object
Returns the routers that are guard routers.
19 20 21 |
# File 'lib/onion/elements/router_list.rb', line 19 def guards @routers.select { |r| r.guard? } end |
#middlemen ⇒ Object
Returns the routers that are neither guard or exit routers.
29 30 31 |
# File 'lib/onion/elements/router_list.rb', line 29 def middlemen @routers.reject { |r| r.guard? or r.exit? } end |