Module: RTM::AR::TOSTRING::Topic

Defined in:
lib/rtm/activerecord/io/to_string.rb

Instance Method Summary collapse

Instance Method Details

#to_s(style = :short) ⇒ Object

Returns different String representations. Try :short (default), :long or something else for the original method. :name returns one (random) name for the Topic or an empty string if the topic has no name



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rtm/activerecord/io/to_string.rb', line 27

def to_s(style=:short)
  case style
  when :short
    ssid = " sids=#{subject_identifiers.to_s}" unless subject_identifiers.empty?
    sslo = " slos=#{subject_locators.to_s}" unless subject_locators.empty?
    siid = " iids=#{item_identifiers.to_s}" unless item_identifiers.empty?
    "#<RTM::Topic id=#{id}#{ssid}#{sslo}#{siid}>"
  when :long
    ssid = " sids=#{subject_identifiers.to_s}" unless subject_identifiers.empty?
    sslo = " slos=#{subject_locators.to_s}" unless subject_locators.empty?
    siid = " iids=#{item_identifiers.to_s}" unless item_identifiers.empty?
    "#<RTM::Topic id=#{id}#{ssid}#{sslo}#{siid} names:#{names.size} occurrences:#{occurrences.size}>"
  when :name
    return names.first.to_s(:short) if names.first
    return ""
  else
    super() # these () are needed, otherwise the own parameters are passed in
  end
end