Current mission: finish filling in the OTDs

SNCA:Ruby

From Soyjak Wiki, the free ensoyclopedia
Jump to navigationJump to search


The average Ruby user looks like this.

Ruby is a programming language created in the 1990s by Yukihiro Matsumoto (who happens to be a mormon, GEEEG) with the goal of making a genuinely object-oriented, easy-to-use scripting language. Ruby is designed to be readable, human-friendly, and lets you write code that almost feels like natural language, similar to Python. Unlike other languages like C# that compile down into intermediate bytecode, Ruby is run as an interpreted language (ev&doe you can use a jit to make code run faster), which means you can write code and see results immediately. Probably the most famous thing built with Ruby is Ruby on Rails, a web development framework that powers sites such as Twitch, GitHub, Shopify, and many other big sites. Rails made it easy to quickly build and scale web apps with a strong emphasis on convention over configuration. Ruby is dynamically typed, and does not support type annotations, ironically making it kind of coal.

Ruby is best known for:

  • Everything is an object. Even numbers like 5 are objects with methods (e.g. 5.even? #=> true).
  • Duck typing over strict types. Ruby doesn’t care about the type of an object as long as it responds to the right methods (the “if it quacks like a duck…” philosophy).
  • Metaprogramming heaven. Ruby lets you define methods on the fly, reopen classes, and even modify core behavior—giving developers a lot of power (and responsibility).
  • Focus on developers. The language was designed to make code feel natural and expressive rather than rigid or boilerplate-heavy. It doesn't take that much to translate Pseudocode into Ruby.
  • Vibrant ecosystem. Ruby has a rich package manager called RubyGems, with thousands of libraries (“gems”) for everything from web servers to game development. RubyGems is just as gemmy as a ruby.

Example[edit | edit source]

# frozen_string_literal: true

module SoyjakParty
  class Tranny
    # Determines whether the tranny should ack based on a given probability.
    # @param ack_probability [Integer] 0–100 chance of acking
    # @return [Boolean] true if roll < ack_probability, else false
    def self.should_ack?(ack_probability)
      ack_probability = [[ack_probability, 0].max, 100].min
      roll = rand * 100
      roll < ack_probability
    end

    # Main function that decides whether to ack or print "TRANS RIGHTS ARE HUMAN RIGHTS!!!!".
    def self.run
      if should_ack?(41)
        raise "ACK!!!!"
      else
        puts "TRANS RIGHTS ARE HUMAN RIGHTS!!!!!!!!"
      end
    end
  end
end

# Run the program
SoyjakParty::Tranny.run

Everything is an object example[edit | edit source]

puts 5.class        # => Integer
puts 5.even?        # => true
puts true.class     # => TrueClass
puts nil.nil?       # => true
puts "hi".upcase    # => "HI"

Psuedocode to Ruby example[edit | edit source]

Psuedocode[edit | edit source]

Do three times 
    print "IF I SAY THIS THREE TIMES THEN YWNBAW"

Ruby[edit | edit source]

3.times do
    puts "IF I SAY THIS THREE TIMES THEN YWNBAW"
end

Ruby is part of a series on Computing

>Nusoicacas really use goyware? KEEEEEEEEEK JSID

➜ /languages

├ /markup/ HTMLCSSXML
├ /low_level/ AssemblyCC++C#Holy CRust
├ /high_level/ JavaGoPHPPythonSQLBashJavaScriptPowerShellActionScriptScratchRubyLuaP
└ /tutorials/ CC++Java

➜ /software

├ /imageboards/ nusoiVichanYotsubaOpenYotsuba
├ /operating_systems/ WindowsLinuxAndroidTempleOSBSD
├ /applications/ Web BrowserPhotoshopFlashMS PaintIRC
├ /dev/ Free-software licenseGame development
└ /misc/ BabybotMcChallengeCAPTCHASystemdRAIDRicing4getSnarkysnappydoxingtool.batJS Paint

➜ /cyb

➜ /misc

├ /file_formats/ GIFMIDISVGWEBMWEBP
└ /hardware/ ThinkPadChromebooks

➜ /ai

SOYNY