class SeriesChecker::Sname

Public Class Methods

new(arg) click to toggle source
# File lib/series_checker.rb, line 4
def initialize(arg)
        @arg = arg
end

Public Instance Methods

is_ap?() click to toggle source
# File lib/series_checker.rb, line 8
def is_ap?
        @arg.each { |x| return false if !x.is_a? Integer}
        len = @arg.length - 1
        temp = Array.new
        count = 1
        for i in (0...len) do
                temp << @arg[i+1] - @arg[i]
        end
        for j in (0...temp.length)
                count += 1 if temp[0] != temp[j]
        end
        return true if count == 1
        return false if count > 1
end
is_gp?() click to toggle source
# File lib/series_checker.rb, line 23
def is_gp?
        @arg.each { |x| return false if !x.is_a? Integer}
        len = @arg.length - 1
        temp = Array.new
        count = 1
        for i in (0...len) do
                temp << @arg[i+1].to_f / @arg[i].to_f
        end
        for j in (0...temp.length)
                count += 1 if temp[0] != temp[j]
        end
        return true if count == 1
        return false if count > 1
end