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.
402 403 404 405 406 407 408 409 410 411 |
# File 'lib/ruote/svc/participant_list.rb', line 402 def initialize(a) @regex = a.first @classname, = 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.
400 401 402 |
# File 'lib/ruote/svc/participant_list.rb', line 400 def classname @classname end |
#options ⇒ Object
Returns the value of attribute options.
400 401 402 |
# File 'lib/ruote/svc/participant_list.rb', line 400 def end |
#regex ⇒ Object
Returns the value of attribute regex.
400 401 402 |
# File 'lib/ruote/svc/participant_list.rb', line 400 def regex @regex end |
Class Method Details
.read(elt) ⇒ Object
Makes sense of whatever is given to it, returns something like
[ regex, [ klass, opts ] ]
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 470 471 472 |
# File 'lib/ruote/svc/participant_list.rb', line 427 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
413 414 415 416 |
# File 'lib/ruote/svc/participant_list.rb', line 413 def to_a [ @regex, [ @classname, ] ] end |
#to_s ⇒ Object
418 419 420 421 |
# File 'lib/ruote/svc/participant_list.rb', line 418 def to_s "/#{@regex}/ ==> #{@classname} #{@options.inspect}" end |