Class: Jacoat::Document::Link

Inherits:
Object
  • Object
show all
Defined in:
lib/jacoat/document/link.rb

Defined Under Namespace

Classes: Complex, Simple

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arguments = {}) ⇒ Link

Returns a new instance of Link.



8
9
10
11
# File 'lib/jacoat/document/link.rb', line 8

def initialize(arguments = {})
  @hash = {}
  process_links(arguments)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/jacoat/document/link.rb', line 13

def method_missing(m, *args)
  #setter
  if /^(\w+)=$/ =~ m 
    @hash[:"#{$1}"] = args[0]
  end
  #getter
  @hash[:"#{m}"]
end

Class Method Details

.process(hash) ⇒ Object



4
5
6
# File 'lib/jacoat/document/link.rb', line 4

def self.process(hash)
  Link.new(hash)
end

Instance Method Details

#to_hashObject



22
23
24
25
26
27
28
# File 'lib/jacoat/document/link.rb', line 22

def to_hash
  hash = {}
  @hash.each_pair do |k, v|
    hash[k] = v.to_hash
  end
  hash
end