Sha256: e3e502171935f95441a728bd71f727d12d212297f2eca3aa1a756bd6942bb535
Contents?: true
Size: 1.02 KB
Versions: 2
Compression:
Stored size: 1.02 KB
Contents
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require 'path' require 'qrb' require 'qrb/syntax' require 'coveralls' Coveralls.wear! class Color def initialize(r, g, b) @r, @g, @b = r, g, b end attr_reader :r, :g, :b def self.rgb(tuple) new(tuple[:r], tuple[:g], tuple[:b]) end def to_rgb { r: @r, g: @g, b: @b } end def self.hex(s) Color.new *[1, 3, 5].map{|i| s[i, 2].to_i(16) } end def to_hex "#" << [r, g, b].map{|i| i.to_s(16) }.join end def ==(other) other.is_a?(Color) and other.to_rgb == self.to_rgb end end module SpecHelpers def intType Qrb::BuiltinType.new(Integer, "intType") end def floatType Qrb::BuiltinType.new(Float, "floatType") end def nilType Qrb::BuiltinType.new(NilClass, "nilType") end def byte Qrb::SubType.new(intType, byte: ->(i){ i>=0 && i<=255 }) end def type_factory Qrb::TypeFactory.new end def blueviolet Color.new(138, 43, 226) end end RSpec.configure do |c| c.include SpecHelpers end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
qrb-0.2.0 | spec/spec_helper.rb |
qrb-0.1.0 | spec/spec_helper.rb |