Sha256: 2d530d4b6c49788418d69af061729947773a2f1db5c1dd9f0952b9a0608f6169
Contents?: true
Size: 1.32 KB
Versions: 3
Compression:
Stored size: 1.32 KB
Contents
require 'soroban/parser' module Soroban # Return true if the supplied data represents a formula. def self.formula?(data) data.to_s.slice(0..0) == '=' end # Return true if the supplied data is a number. def self.number?(data) Float(data.to_s) && true rescue false end # Return true if the supplied data is a boolean. def self.boolean?(data) /^(true|false)$/i.match(data.to_s) && true || false end # Return true if the supplied data is a string. def self.string?(data) /^["](\"|[^"])*["]$/.match(data.to_s) && true || /^['][^']*[']$/.match(data.to_s) && true || false end # Return true if the supplied data is a range. def self.range?(data) /^([a-zA-Z]+)([\d]+):([a-zA-Z]+)([\d]+)$/.match(data.to_s) && true || false end # Return true if the supplied data is of no recognised format. def self.unknown?(data) !self.formula?(data) && !self.number?(data) && !self.boolean?(data) && !self.string?(data) end # Return the components of a range. def self.getRange(range) /^([a-zA-Z]+)([\d]+):([a-zA-Z]+)([\d]+)$/.match(range.to_s).to_a[1..-1] end # Return an array of values for the supplied arguments (which may be numbers, labels and ranges). def self.getValues(binding, *args) args.map { |arg| Soroban::range?(arg) ? Walker.new(arg, binding).map : arg }.flatten end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
soroban-0.1.1 | lib/soroban/helpers.rb |
soroban-0.1.0 | lib/soroban/helpers.rb |
Soroban-0.1.0 | lib/soroban/helpers.rb |