24件ヒット
[1-24件を表示]
(0.033秒)
別のキーワード
キーワード
- NKF (12)
- Observable (12)
検索結果
先頭2件
-
Observable (31.0)
-
Observer パターンを提供するモジュールです。
...require "observer"
class Ticker ### Periodically fetch a stock price.
include Observable
def initialize(symbol)
@symbol = symbol
end
def run
last_price = nil
loop do
price = Price.fetch(@symbol)
print "Current price: #{price}\n"......y_observers(Time.now, price)
end
sleep 1
end
end
end
class Price ### A mock class to fetch a stock price (60 - 140).
def self.fetch(symbol)
60 + rand(80)
end
end
class Warner ### An abstract observer of Ticker objects.
def init......price > @limit
print "+++ #{time.to_s}: Price above #@limit: #{price}\n"
end
end
end
ticker = Ticker.new("MSFT")
WarnLow.new(ticker, 80)
WarnHigh.new(ticker, 120)
ticker.run
# => Current price: 126
# => +++ 2017-11-02 12:09:36 +0900: Price above 120: 126
# => Curr... -
NKF (25.0)
-
nkf(Network Kanji code conversion Filter, https://osdn.net/projects/nkf/) を Ruby から使うためのモジュールです。
...]{
#!/usr/local/bin/ruby
require 'nkf'
CODES = {
NKF::JIS => "JIS",
NKF::EUC => "EUC",
NKF::SJIS => "SJIS",
NKF::UTF8 => "UTF8",
NKF::BINARY => "BINARY",
NKF::ASCII => "ASCII",
NKF::UNKNOWN => "UNKNOWN",
}
while file = ARGV.shift
str = open(file) {|io| io.g......ets(nil) }
printf "%-10s ", file
if str.nil?
puts "EMPTY"
else
puts CODES.fetch(NKF.guess(str))
end
end
//}
=== オプション文字列
-b 入力がバッファリングされる(デフォルト)
-u 入力がバッファリングされない
-j -s -e -w -w16 出力する......‘’“”()[]{}〈〉+−=<>$%#&*@
-Z1 X0208空白(いわゆる全角空白)を ASCII の空白に変換する
-Z2 X0208空白(いわゆる全角空白)を ASCII の空白2つに変換する
-Z3 X0208の>、<、”、&、を '>', '<', '"...