View class_reference.rb
def main
loop do
name = choise(class_list, combine: true)
clear
puts Module.const_get(name).info
puts
choise(["戻る"])
clear
View github_download.rb
def bget(url, token)
if token
ret = Browser.get(url, header: { "Authorization" => "token #{token}"})
else
ret = Browser.get(url)
end
JSON::parse(ret)
end
View matching-and-dynamic-schemas.rb
require "rspec"
require "json"
require "dry-types"
require "dry-validation"
module Types
include Dry::Types.module
RegionCode = Types::Strict::String.constrained(
format: /\A(au|nz|uk|ie)\z/,
View rom-http-repo-aggregate.rb
require 'bundler/inline'
require 'json'
require 'uri'
require 'net/http'
gemfile(true) do
gem 'inflecto'
gem 'rom', github: 'rom-rb/rom'
gem 'rom-support', github: 'rom-rb/rom-support'
gem 'rom-http', github: 'rom-rb/rom-http'
View dry_v_either_filled.rb
require 'dry-validation'
schema = Dry::Validation.Schema do
configure do
def self.messages
super.merge(en: { errors: { foo: 'either a or b can be filled' } })
end
end
required(:a).maybe
View rom-sql-ar-like-polymorphic-associations.rb
require 'rom-repository'
require 'rom-sql'
require 'logger'
config = ROM::Configuration.new(:sql, 'sqlite::memory')
config.gateways[:default].connection.create_table(:songs) do
primary_key :id
column :title, String
end
View udp_server.rb
require 'bundler/setup'
require 'concurrent-edge'
require 'logger'
Concurrent.use_stdlib_logger Logger::DEBUG
class MyUDPServer < Concurrent::Actor::Context
def initialize
super
View othero.rb
require "drb/drb"
module Othero
class Board
include Enumerable
attr_reader :size
Size = {:small => 6, :medium => 8, :large => 10}
def initialize(size= :small)
@size = Size[size]
@cells = Array.new(@size){ Array.new(@size) }
View appexplore.rb
# explore APPS and app (s)
# don't name anything as 'app' unless you enjoy confusion
class Shoes::Types::App
def myinspect(target, from)
puts "For #{target.name} (from #{app.name})"
#puts "app and from are same object: #{target === app}"
puts "instance vars"
puts "#{target.inspect}"
puts target.instance_variables
View date_picker_module
require 'green_shoes'
module DatePicker
def set_no_days
@no_of_days = case @month
when 4 then 1..30
when 6 then 1..30
when 9 then 1..30
when 11 then 1..30