Class: TypographicUnit::Gou

Inherits:
Unit
  • Object
show all
Defined in:
lib/typographic-unit/gou.rb

Overview

Gou is a unit of Japanese Gou(号). See www.um.u-tokyo.ac.jp/publish_db/1996Moji/05/5901.html and www.asahi-net.or.jp/~ax2s-kmtn/ref/type_size.html for details. In this library, “初号” is Gou.new(:first) or 0.gou.

Instance Attribute Summary

Attributes inherited from Unit

#value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Unit

#%, #*, #+, #+@, #-, #-@, #<=>, #>>, #abs, base, #ceil, #div, #floor, #inspect, #integer?, #nonzero?, #quo, register, #round, short, size, #step, #to_f, #to_i, #to_int, #to_s, #truncate, unit, #zero?

Constructor Details

#initialize(value) ⇒ Gou

Returns a new instance of Gou.



10
11
12
13
14
15
16
17
18
# File 'lib/typographic-unit/gou.rb', line 10

def initialize(value)
  if value.kind_of?(Unit)
    raise ArgumentError.new, value
  end
  unless (0..8).include?(value) or value == :first
    raise ArgumentError.new, value
  end
  @value = value
end

Class Method Details

.firstObject

Return a size according to “初号”.



21
22
23
# File 'lib/typographic-unit/gou.rb', line 21

def self.first
  0.gou
end

Instance Method Details

#scaled_pointObject

Convert the value into american point.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/typographic-unit/gou.rb', line 26

def scaled_point
  val = case @value
        when :first, 0
          42.american_pt
        when 1
          27.5.american_pt
        when 2
          21.american_pt
        when 3
          15.75.american_pt
        when 4
          13.75.american_pt
        when 5
          10.5.american_pt
        when 6
          7.875.american_pt
        when 7
          5.25.american_pt
        when 8
          3.9375.american_pt
        end
  val.kind_of?(ScaledPoint) ? val : val.scaled_point
end