るりまサーチ

最速Rubyリファレンスマニュアル検索!
26件ヒット [1-26件を表示] (0.034秒)
トップページ > クエリ:Data[x] > クエリ:get[x] > クエリ:define[x]

別のキーワード

  1. net/imap data
  2. net/imap raw_data
  3. socket data
  4. smtp data
  5. net/smtp data

種類

ライブラリ

クラス

キーワード

検索結果

Data.define(*args) -> Class (39250.0)

Data クラスに新しいサブクラスを作って、それを返します。

...
Data
クラスに新しいサブクラスを作って、それを返します。

サブクラスでは値オブジェクトのメンバに対するアクセスメソッドが定義されています。

//emlist[例][ruby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
p fred.name # =>...
...]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
fred.age = 6 # => NoMethodError
//}

メンバを持たないサブクラスも定義可能です。
以下のように、パターンマッチに利用できます。

//emlist[例][ruby]{
class HTTPFetcher
Response = Data.define(:body)...
...NotFound = Data.define

def get(url)
# ダミーの実装
if url == "http://example.com/"
Response.new(body: "Current time is #{Time.now}")
else
NotFound.new
end
end
end

def fetch(url)
fetcher = HTTPFetcher.new
case fetcher.get(url)
in HTTPFetcher::Response(b...

Data.define(*args) {|subclass| block } -> Class (39250.0)

Data クラスに新しいサブクラスを作って、それを返します。

...
Data
クラスに新しいサブクラスを作って、それを返します。

サブクラスでは値オブジェクトのメンバに対するアクセスメソッドが定義されています。

//emlist[例][ruby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
p fred.name # =>...
...]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
fred.age = 6 # => NoMethodError
//}

メンバを持たないサブクラスも定義可能です。
以下のように、パターンマッチに利用できます。

//emlist[例][ruby]{
class HTTPFetcher
Response = Data.define(:body)...
...NotFound = Data.define

def get(url)
# ダミーの実装
if url == "http://example.com/"
Response.new(body: "Current time is #{Time.now}")
else
NotFound.new
end
end
end

def fetch(url)
fetcher = HTTPFetcher.new
case fetcher.get(url)
in HTTPFetcher::Response(b...

NEWS for Ruby 2.0.0 (54.0)

NEWS for Ruby 2.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...を導入しました。期待しないスタックオーバーフローを避けるためです

* GC::Profiler
* 追加: GC::Profiler.raw_data GCの加工していないプロファイルデータを返します

* Hash
* 追加: Hash#to_h 明示的に変換するメソッドです。A...
...張します。
* 拡張: Module#define_method は UnboundMethod を受け付けるようになりました
* 拡張: Module#const_get 修飾された定数名の文字列を受け付けるようになりました。
//emlist{
Object.const_get("Foo::Bar::Baz")
//}

* Mutex
*...
...* Process
* 追加: Process#getsid session id を取得します(unix のみ)。

* Range
* 追加: Range#size サイズの遅延評価
* 追加: Range#bsearch 二分探索

* RubyVM (MRI specific)
* 追加: RubyVM::InstructionSequence.of to get the instruction sequence
f...

NEWS for Ruby 2.1.0 (30.0)

NEWS for Ruby 2.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...のペアの配列をハッシュに変換します。

* Binding
* 追加: Binding#local_variable_get
* 追加: Binding#local_variable_set
* 追加: Binding#local_variable_defined?

* Enumerable
* 追加: Enumerable#to_h キーと値のペアのリストをハッシュに変換...
...基数変換、GCD

* IO
* 拡張: IO#seek SEEK_DATA と SEEK_HOLE を whence としてサポートしました??
* 拡張: IO#seek 第2引数としてシンボルを受け付けるようになりました (:CUR, :END, :SET, :DATA, :HOLE)
* 拡張: IO#read_nonblock シンボルを...
...追加: Process.#setproctitle $0 に影響を与えずにプロセス名をセットできます。
* 追加: Process.#clock_gettime
* 追加: Process.#clock_getres

* String
* "literal".freeze は同じオブジェクトを返すように最適化されました。
* 追加: Stri...