Class: Numeric

Inherits:
Object show all
Defined in:
lib/Miyako/API/layout.rb

Overview

– Miyako v2.1 Copyright (C) 2007-2009 Cyross Makoto

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++

Instance Method Summary collapse

Instance Method Details

#percent(base) ⇒ Object

自身の値をパーセンテージとして、値を算出する

base

算出元の値

返却値

baseのself%の値を返す

(例)self=10、base=100のとき、100*10/100(%)=10が出力される


38
39
40
# File 'lib/Miyako/API/layout.rb', line 38

def percent(base)
  return self * base / 100
end

#pxObject

ピクセル値をそのまま返す

返却値

自分自身を返す


44
45
46
# File 'lib/Miyako/API/layout.rb', line 44

def px
  return self
end

#ratio(base) ⇒ Object

自身の値を割合として、値を算出する

base

算出元の値

返却値

baseのself割りの値を返す

(例)self=0.5、base=1000のとき、1000*0.5=500が出力される


29
30
31
# File 'lib/Miyako/API/layout.rb', line 29

def ratio(base)
  return self * base
end