Parent

Files

Class/Module Index [+]

Quicksearch

Jpmobile::Mobile::Terminfo

Public Class Methods

new(carrier, env) click to toggle source
# File lib/jpmobile/mobile/terminfo.rb, line 6
def initialize(carrier, env)
  case carrier.class.name
  when /Docomo/
    display_info    = Docomo::DISPLAY_INFO[carrier.model_name] || {}
    @browser_width  = display_info[:browser_width]
    @browser_height = display_info[:browser_height]
    @color_p        = display_info[:color_p]
    @colors         = display_info[:colors]
  when /Au/
    if r = env['HTTP_X_UP_DEVCAP_SCREENPIXELS']
      @physical_width, @physical_height = r.split(/,/,2).map {|x| x.to_i}
    end
    if r = env['HTTP_X_UP_DEVCAP_ISCOLOR']
      @color_p = (r == '1')
    end
    if r = env['HTTP_X_UP_DEVCAP_SCREENDEPTH']
      a = r.split(/,/)
      @colors = 2 ** a[0].to_i
    end
  when /Softbank/, /Vodafone/
    if r = env['HTTP_X_JPHONE_DISPLAY']
      @physical_width, @physical_height = r.split(/\*/,2).map {|x| x.to_i}
    end
    if r = env['HTTP_X_JPHONE_COLOR']
      case r
      when /^C/
        @color_p = true
      when /^G/
        @color_p = false
      end
      if r =~ /^.(\d+)$/
        @colors = $1.to_i
      end
    end
  end
end

Public Instance Methods

browser_height() click to toggle source

ブラウザの画面高さを返す。不明の場合は nil

# File lib/jpmobile/mobile/terminfo.rb, line 54
def browser_height; @browser_height; end
browser_width() click to toggle source

ブラウザの画面幅を返す。不明の場合は nil

# File lib/jpmobile/mobile/terminfo.rb, line 52
def browser_width; @browser_width; end
color?() click to toggle source

画面がカラーならば true、白黒ならば false を返す。不明の場合は nil

# File lib/jpmobile/mobile/terminfo.rb, line 44
def color?; @color_p; end
colors() click to toggle source

画面の色数を返す。不明の場合は nil

# File lib/jpmobile/mobile/terminfo.rb, line 46
def colors; @colors; end
height() click to toggle source

画面の高さを返す。ブラウザ画面の高さがわかる場合はそれを優先する。不明の場合は nil

# File lib/jpmobile/mobile/terminfo.rb, line 58
def height; browser_height || physical_height; end
physical_height() click to toggle source

ディスプレイの画面高さを返す。不明の場合は nil

# File lib/jpmobile/mobile/terminfo.rb, line 50
def physical_height; @physical_height; end
physical_width() click to toggle source

ディスプレイの画面幅を返す。不明の場合は nil

# File lib/jpmobile/mobile/terminfo.rb, line 48
def physical_width; @physical_width; end
width() click to toggle source

画面の幅を返す。ブラウザ画面の幅がわかる場合はそれを優先する。不明の場合は nil

# File lib/jpmobile/mobile/terminfo.rb, line 56
def width; browser_width || physical_width; end

[Validate]

Generated with the Darkfish Rdoc Generator 2.