Class: RubyIdn

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_idn.rb,
lib/ruby_idn/version.rb

Constant Summary collapse

VERSION =
"0.1.0"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:) ⇒ RubyIdn

Returns a new instance of RubyIdn.



7
8
9
# File 'lib/ruby_idn.rb', line 7

def initialize(name:)
  @name = name
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/ruby_idn.rb', line 5

def name
  @name
end

Class Method Details

.to_ascii(domain) ⇒ Object



24
25
26
27
# File 'lib/ruby_idn.rb', line 24

def to_ascii(domain)
  ret_domain = to_stringprep(domain)
  call_idn(domain: ret_domain, options: '--idna-to-ascii')
end

.to_nameprep(domain) ⇒ Object



38
39
40
# File 'lib/ruby_idn.rb', line 38

def to_nameprep(domain)
  call_idn(domain: domain, options: ['--profile', 'Nameprep'])
end

.to_stringprep(domain) ⇒ Object



34
35
36
# File 'lib/ruby_idn.rb', line 34

def to_stringprep(domain)
  call_idn(domain: domain, options: '--stringprep')
end

.to_unicode(domain) ⇒ Object



29
30
31
32
# File 'lib/ruby_idn.rb', line 29

def to_unicode(domain)
  ret_domain = to_stringprep(domain)
  call_idn(domain: ret_domain, options: '--idna-to-unicode')
end

Instance Method Details

#ascii_nameObject



15
16
17
# File 'lib/ruby_idn.rb', line 15

def ascii_name
  self.class.to_ascii(name)
end

#unicode_nameObject



19
20
21
# File 'lib/ruby_idn.rb', line 19

def unicode_name
  self.class.to_unicode(name)
end