Sha256: 27fa4fd977c37d5c2e1d790d5aba57bee1f341a9147949f274b36f0a64dcb961

Contents?: true

Size: 1.43 KB

Versions: 23

Compression:

Stored size: 1.43 KB

Contents

#!/usr/bin/env ruby -w
# encoding: UTF-8
#
# = DumpedField.rb -- Fit4Ruby - FIT file processing library for Ruby
#
# Copyright (c) 2016 by Chris Schlaeger <cs@taskjuggler.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#

module Fit4Ruby

  # If the user has requested a dump of the records, this class is used to
  # capture a subset of the field related information for the later textual
  # dump.
  class DumpedField

    attr_reader :message_number, :field_number

    # Create a new field dump record.
    # @param message_number [Fixnum] The global message number of the message
    #        this field belongs to.
    # @param field_number [Fixnum] The number of the FIT message field
    # @param name [String] The name of the field
    # @param type [Symbol] The type of the field
    # @param value [String] A human readable dump of the field value
    def initialize(message_number, field_number, name, type, value)
      @message_number = message_number
      @field_number = field_number
      @name = name
      @type = type
      @value = value
    end

    def <=>(f)
      @field_number <=> f.field_number
    end

    def to_s(index)
      "[#{'%03d' % @message_number}:#{'%03d' % index}:" +
      "#{'%03d' % @field_number}:" +
      "#{"%-7s" % @type}] #{@name}: " + "#{@value}"
    end

  end

end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
fit4ruby-3.13.0 lib/fit4ruby/DumpedField.rb
fit4ruby-3.12.0 lib/fit4ruby/DumpedField.rb
fit4ruby-3.11.0 lib/fit4ruby/DumpedField.rb
fit4ruby-3.10.0 lib/fit4ruby/DumpedField.rb
fit4ruby-3.9.0 lib/fit4ruby/DumpedField.rb
fit4ruby-3.8.0 lib/fit4ruby/DumpedField.rb
fit4ruby-3.7.0 lib/fit4ruby/DumpedField.rb
fit4ruby-3.6.0 lib/fit4ruby/DumpedField.rb
fit4ruby-3.5.0 lib/fit4ruby/DumpedField.rb
fit4ruby-3.4.0 lib/fit4ruby/DumpedField.rb
fit4ruby-3.3.0 lib/fit4ruby/DumpedField.rb
fit4ruby-3.2.0 lib/fit4ruby/DumpedField.rb
fit4ruby-3.1.0 lib/fit4ruby/DumpedField.rb
fit4ruby-3.0.0 lib/fit4ruby/DumpedField.rb
fit4ruby-2.0.0 lib/fit4ruby/DumpedField.rb
fit4ruby-1.7.0 lib/fit4ruby/DumpedField.rb
fit4ruby-1.6.2 lib/fit4ruby/DumpedField.rb
fit4ruby-1.6.1 lib/fit4ruby/DumpedField.rb
fit4ruby-1.6.0 lib/fit4ruby/DumpedField.rb
fit4ruby-1.5.1 lib/fit4ruby/DumpedField.rb