githubnext / monaspace

An innovative superfamily of fonts for code
https://monaspace.githubnext.com
SIL Open Font License 1.1
13.18k stars 220 forks source link

Add Ruby code preview to website #40

Open krmbzds opened 8 months ago

krmbzds commented 8 months ago

I want to see how it looks with Ruby source code.

image

Feel free to use this snippet:

class Person
 attr_accessor :name, :age

 def initialize(name, age)
   @name = name
   @age += age
 end

 def ==(other)
   @name == other.name && @age == other.age
 end

 def <=>(other)
   @age <=> other.age
 end

 def !~(other)
   @name !~ other.name || @age != other.age
 end

 def =~(other)
   @name =~ other.name && @age == other.age
 end

 def <<(other)
   @name << other.name
 end

 def >>(other)
   @age >> other.age
 end

 def **(other)
   @age ** other.age
 end

 def &&(other)
   @name && other.name && @age && other.age
 end

 def ||(other)
   @name || other.name || @age || other.age
 end
end

alice = Person.new("Alice", 30)
bob = Person.new("Bob", 35)

puts alice == bob # => false
puts alice <=> bob # => -1
puts alice !~ bob # => true
puts alice =~ bob # => false
puts alice << bob # => "AliceBob"
puts alice >> bob # => 30
puts alice ** bob # => 9000000000000000
puts alice && bob # => true
puts alice || bob # => true
idan commented 7 months ago

Need a better snippet that demonstrates texture healing, but otherwise yeah, would be happy to add a Ruby example here.