Sha256: 6f215f5d8241e3801d721b388e459b9a249b423ff7c8db1905f78c73a830da52

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

module Player

  class PlayerTemplate
    attr_accessor :player
    def initialize(player)
      @player = player
    end

    def figure_lead_and_trailing_zeroes(arg)
      revised_number = self.remove_leading_zero(arg)

      if revised_number.length === 3
        revised_number = "#{revised_number}0"
      elsif revised_number.length === 2
        revised_number = "#{revised_number}00"
      else
        return revised_number
      end
    end

    def third_of_an_inning_handler(innings)
      innings_string = innings.to_s
      final_fig = innings_string[0..(innings_string.length - 2)]
      final_num = innings_string[(innings_string.length - 2)..innings_string.length].to_f
      returnable_innings = final_fig.to_f
      if final_num == 0.1
        returnable_innings += 0.33
        returnable_innings.to_s
      elsif final_num == 0.2
        returnable_innings += 0.66
        returnable_innings.to_s
      else
        innings
      end
    end

    def remove_leading_zero(arg)
      arg.to_s.sub("0", "")
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
baseball-1.2.0 lib/baseball/player.rb
baseball-1.1.0 lib/baseball/player.rb