Class | InputOption
In: | app/models/input_option.rb
Parent: | ActiveRecord::Base

入力の選択肢のモデル。

### Methods

name_po_with_category name_po_with_category_and_name name_pos_with_category name_pos_with_category_and_head name_pos_with_category_and_include name_pos_with_category_and_tail option_name options_for_select

### Public Class methods

name_po_with_category(category, &block)

[Source]

        # File app/models/input_option.rb, line 42
    42:   def self.name_po_with_category(category, &block)
    43:     options = find(:all, :conditions => {:category => category})
    44:     (o = options.find(&block)) ? o.name_po : -1
    45:   end

name_po_with_category_and_name(category, name)

対応する値を持つ選択肢の name_po を返す。

[Source]

        # File app/models/input_option.rb, line 53
    53:   def self.name_po_with_category_and_name(category, name)
    54:     name_po_with_category(category) {|o| o.name == name}
    55:   end

name_pos_with_category(category, &block)

[Source]

        # File app/models/input_option.rb, line 47
    47:   def self.name_pos_with_category(category, &block)
    48:     options = find(:all, :conditions => {:category => category})
    49:     options.select(&block).map(&:name_po).compact
    50:   end

name_pos_with_category_and_head(category, head)

対応する値を持つ選択肢の name_po の配列を返す。

[Source]

        # File app/models/input_option.rb, line 58
    58:   def self.name_pos_with_category_and_head(category, head)
    59:     name_pos_with_category(category) {|o| o.name.index(head) == 0}
    60:   end

name_pos_with_category_and_include(category, sub)

対応する値を持つ選択肢の name_po の配列を返す。

[Source]

        # File app/models/input_option.rb, line 68
    68:   def self.name_pos_with_category_and_include(category, sub)
    69:     name_pos_with_category(category) {|o| o.name.include?(sub)}
    70:   end

name_pos_with_category_and_tail(category, tail)

対応する値を持つ選択肢の name_po の配列を返す。

[Source]

        # File app/models/input_option.rb, line 63
    63:   def self.name_pos_with_category_and_tail(category, tail)
    64:     name_pos_with_category(category) {|o| o.name.rindex(tail) == o.name.length - tail.length}
    65:   end

option_name(category, value)

対応する値を持つ選択肢の名前を返す。

[Source]

        # File app/models/input_option.rb, line 38
    38:   def self.option_name(category, value)
    39:     (i = find(:first, :conditions => {:category => category, :value => value})) && i.name
    40:   end

options_for_select(category, limit=nil)

category に属する選択肢を返す。

[Source]

        # File app/models/input_option.rb, line 31
    31:   def self.options_for_select(category, limit=nil)
    32:     options = {:conditions => {:category => category}, :order => "position,id"}
    33:     options[:limit] = limit if limit
    34:     find(:all, options).map {|p| [p.name, p.value]}
    35:   end

[Validate]