Class: String

Inherits:
Object show all
Defined in:
lib/wukong/extensions/blank.rb,
lib/wukong/schema.rb,
lib/wukong/schema.rb,
lib/wukong/schema.rb,
lib/wukong/schema.rb,
lib/wukong/encoding/asciize.rb

Overview

Direct Known Subclasses

Wukong::Datatypes::Blob, Wukong::Datatypes::Csv, Wukong::Datatypes::FilePath, Wukong::Datatypes::Flag, Wukong::Datatypes::IPAddress, Wukong::Datatypes::Json, Wukong::Datatypes::Text, Wukong::Datatypes::URI, Wukong::Datatypes::Yaml

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) to_avro



64
# File 'lib/wukong/schema.rb', line 64

def to_avro() 'string'        end

+ (Object) to_pig



35
# File 'lib/wukong/schema.rb', line 35

def to_pig() 'chararray'     end

+ (Object) to_sql



10
# File 'lib/wukong/schema.rb', line 10

def to_sql() 'VARCHAR(255) CHARACTER SET ASCII' end

Instance Method Details

- (Object) asciize(name)



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/wukong/encoding/asciize.rb', line 15

def asciize(name)
  if name =~ /[^\x00-\x7F]/
    # digraphs.  May be culturally sensitive
    name.gsub! /\xc3\x9f/, 'ss'
    name.gsub! /\xc3\xa4|a\xcc\x88/, 'ae'
    name.gsub! /\xc3\xa5|a\xcc\x8a/, 'aa'
    name.gsub! /\xc3\xa6/, 'ae'
    name.gsub! /\xc3\xb1|n\xcc\x83/, 'ny'
    name.gsub! /\xc3\xb6|o\xcc\x88/, 'oe'
    name.gsub! /\xc3\xbc|u\xcc\x88/, 'ue'

    # latin 1
    name.gsub! /\xc3[\xa0-\xa5]/, 'a'
    name.gsub! /\xc3\xa7/, 'c'
    name.gsub! /\xc3[\xa8-\xab]/, 'e'
    name.gsub! /\xc3[\xac-\xaf]/, 'i'
    name.gsub! /\xc3[\xb2-\xb6]|\xc3\xb8/, 'o'
    name.gsub! /\xc3[\xb9-\xbc]/, 'u'
    name.gsub! /\xc3[\xbd\xbf]/, 'y'

    # Latin Extended-A
    name.gsub! /\xc4[\x80-\x85]/, 'a'
    name.gsub! /\xc4[\x86-\x8d]/, 'c'
    name.gsub! /\xc4[\x8e-\x91]/, 'd'
    name.gsub! /\xc4[\x92-\x9b]/, 'e'
    name.gsub! /\xc4[\x9c-\xa3]/, 'g'
    name.gsub! /\xc4[\xa4-\xa7]/, 'h'
    name.gsub! /\xc4[\xa8-\xb1]/, 'i'
    name.gsub! /\xc4[\xb2-\xb3]/, 'ij'
    name.gsub! /\xc4[\xb4-\xb5]/, 'j'
    name.gsub! /\xc4[\xb6-\xb8]/, 'k'
    name.gsub! /\xc4[\xb9-\xff]|\xc5[\x80-\x82]/, 'l'
    name.gsub! /\xc5[\x83-\x8b]/, 'n'
    name.gsub! /\xc5[\x8c-\x91]/, 'o'
    name.gsub! /\xc5[\x92-\x93]/, 'oe'
    name.gsub! /\xc5[\x94-\x99]/, 'r'
    name.gsub! /\xc5[\x9a-\xa2]/, 's'
    name.gsub! /\xc5[\xa2-\xa7]/, 't'
    name.gsub! /\xc5[\xa8-\xb3]/, 'u'
    name.gsub! /\xc5[\xb4-\xb5]/, 'w'
    name.gsub! /\xc5[\xb6-\xb8]/, 'y'
    name.gsub! /\xc5[\xb9-\xbe]/, 'z'

    # denormalized diacritics
    name.gsub! /\xcc[\x80-\xff]|\xcd[\x80-\xaf]/, ''
  end

  name.gsub /[^\w]+/, '-'
end

- (Boolean) blank?

Returns:



90
91
92
# File 'lib/wukong/extensions/blank.rb', line 90

def blank?
  strip.empty?
end

- (Object) to_avro



68
# File 'lib/wukong/schema.rb', line 68

def to_avro() self.to_s ;     end

- (Object) to_pig



39
# File 'lib/wukong/schema.rb', line 39

def to_pig() self.to_s ; end

- (Object) to_sql



22
# File 'lib/wukong/schema.rb', line 22

def to_sql() self             ; end