Module: RTM::IO::ToString::Topic

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

Instance Method Summary

Instance Method Details

- (Object) to_s(style = :short)

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



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'rtm/lib/rtm/io/to_string.rb', line 35

def to_s(style=:short)
  case style
  when :short
    ssid = " sids=#{delocatorized subject_identifiers}" unless subject_identifiers.empty?
    sslo = " slos=#{delocatorized subject_locators}" unless subject_locators.empty?
    siid = " iids=#{delocatorized item_identifiers}" unless item_identifiers.empty?
    "#<RTM::Topic id=#{id}#{ssid}#{sslo}#{siid}>"
  when :long
    ssid = " sids=#{delocatorized subject_identifiers}" unless subject_identifiers.empty?
    sslo = " slos=#{delocatorized subject_locators}" unless subject_locators.empty?
    siid = " iids=#{delocatorized item_identifiers}" 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