Class: Ruote::ParticipantEntry
- Inherits:
-
Object
- Object
- Ruote::ParticipantEntry
- Defined in:
- lib/ruote/svc/participant_list.rb
Overview
A helper class, for ParticipantList#list, which returns a list (order matters) of ParticipantEntry instances.
See Engine#participant_list
Instance Attribute Summary collapse
-
#classname ⇒ Object
Returns the value of attribute classname.
-
#options ⇒ Object
Returns the value of attribute options.
-
#regex ⇒ Object
Returns the value of attribute regex.
Class Method Summary collapse
-
.read(elt) ⇒ Object
Makes sense of whatever is given to it, returns something like.
Instance Method Summary collapse
-
#initialize(a) ⇒ ParticipantEntry
constructor
A new instance of ParticipantEntry.
- #to_a ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(a) ⇒ ParticipantEntry
Returns a new instance of ParticipantEntry.
399 400 401 402 403 404 405 406 407 408 |
# File 'lib/ruote/svc/participant_list.rb', line 399 def initialize(a) @regex = a.first @classname, @options = if a.last.is_a?(Array) [ a.last.first, a.last.last ] else [ a.last, nil ] end end |
Instance Attribute Details
#classname ⇒ Object
Returns the value of attribute classname.
397 398 399 |
# File 'lib/ruote/svc/participant_list.rb', line 397 def classname @classname end |
#options ⇒ Object
Returns the value of attribute options.
397 398 399 |
# File 'lib/ruote/svc/participant_list.rb', line 397 def @options end |
#regex ⇒ Object
Returns the value of attribute regex.
397 398 399 |
# File 'lib/ruote/svc/participant_list.rb', line 397 def regex @regex end |
Class Method Details
.read(elt) ⇒ Object
Makes sense of whatever is given to it, returns something like
[ regex, [ klass, opts ] ]
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 |
# File 'lib/ruote/svc/participant_list.rb', line 424 def self.read(elt) case elt when ParticipantEntry elt.to_a when Hash = elt['options'] || elt.reject { |k, v| %w[ name regex regexp class classname ].include?(k) } name, _ = elt.find { |k, v| v == nil } if name elt.delete(name) .delete(name) end name = name || elt['name'] name = Ruote.regex_or_s(name) regex = name if name.nil? regex = Ruote.regex_or_s(elt['regex'] || elt['regexp']) regex = regex.is_a?(String) ? Regexp.new(regex) : regex end klass = (elt['classname'] || elt['class']).to_s [ regex, [ klass, ] ] when Array if elt.size == 3 [ Ruote.regex_or_s(elt[0]), [ elt[1].to_s, elt[2] ] ] else [ Ruote.regex_or_s(elt[0]), elt[1] ] end else raise ArgumentError.new( "cannot read participant out of #{elt.inspect} (#{elt.class})") end end |
Instance Method Details
#to_a ⇒ Object
410 411 412 413 |
# File 'lib/ruote/svc/participant_list.rb', line 410 def to_a [ @regex, [ @classname, @options ] ] end |
#to_s ⇒ Object
415 416 417 418 |
# File 'lib/ruote/svc/participant_list.rb', line 415 def to_s "/#{@regex}/ ==> #{@classname} #{@options.inspect}" end |