This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Создайте новый файл oop_practice.rb. | |
# 1. Добавьте туда два класса - Notebook и Note. | |
# 2. У класса Note есть метод share, который меняет атрибут shared объекта этого класса с false на true | |
# 3. У класса Note есть атрибуты shared и text | |
# 4. У класса Notebook есть методы add_note, clean (удаляет все заметки) | |
# 5. Ещё у Notebook есть атрибут с массивом заметок | |
# 6. Ещё есть класс SharedNotebook, подкласс класса Notebook | |
# 7. У него переопределяется метод add_note, любая добавленная в него заметка становится shared | |
# 8. Ещё у _самого класса_ SharedNotebook есть метод count, который возвращает количество созданных SharedNotebook |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "redis" | |
class Test | |
attr_reader :quit | |
def initialize | |
@redis = Redis.new | |
end | |
def trap_signal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'net/telnet' | |
require 'tor_requests' | |
require 'json' | |
def switch_endpoint | |
localhost = Net::Telnet::new("Host" => "localhost", "Port" => "9050", "Timeout" => 10, "Prompt" => /250 OK\n/) | |
localhost.cmd('AUTHENTICATE "hi"') { |c| print c; throw "Cannot authenticate to Tor" if c != "250 OK\n" } | |
localhost.cmd('signal NEWNYM') { |c| print c; throw "Cannot switch Tor to new route" if c != "250 OK\n" } |
NewerOlder