Sha256: 69c38298e21aeb3cfe21f2aca993f3a1b713655c712489fd4eb2b9c51b803bb5

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

class RFlow
  module Components
    module IRC
      # @!visibility private
      module Extensions
        # @!visibility private
        module IRCMessageExtension
          # @!visibility private
          def self.extended(base_data)
            base_data.data_object ||= {'timestamp' => Time.now.xmlschema, 'prefix' => nil, 'command' => 'PRIVMSG', 'parameters' => []}
          end

          # Default accessors
          ['prefix', 'command', 'parameters'].each do |name|
            define_method name do |*args|
              data_object[name]
            end

            define_method :"#{name}=" do |*args|
              data_object[name] = args.first
            end
          end

          # Timestamp Accessors.  Note, the precision of the
          # XMLTimestamp is set to 9 digits, meaning that the time you
          # put in might be slightly different from the time you read
          # out.
          ['timestamp'].each do |name|
            define_method name do |*args|
              data_object[name] ? Time.xmlschema(data_object[name]) : nil
            end

            define_method :"#{name}=" do |*args|
              if args.first.is_a? Time
                data_object[name] = args.first.xmlschema(9)
              else
                data_object[name] = args.first
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rflow-components-irc-1.1.1 lib/rflow/components/irc/extensions.rb