Class: RbLatex::MetaInfo

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/rb_latex/meta_info.rb

Constant Summary collapse

ATTRS =
%i(title creator page_progression_direction language publisher)

Constants included from Utils

Utils::ESCAPE_CHARS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

escape_latex

Constructor Details

#initializeMetaInfo

Returns a new instance of MetaInfo.



13
14
15
16
# File 'lib/rb_latex/meta_info.rb', line 13

def initialize
  @creator = Hash.new
  @pubdate = nil
end

Instance Attribute Details

#lastmodifiedObject

Returns the value of attribute lastmodified.



11
12
13
# File 'lib/rb_latex/meta_info.rb', line 11

def lastmodified
  @lastmodified
end

#pubdateObject

Returns the value of attribute pubdate.



11
12
13
# File 'lib/rb_latex/meta_info.rb', line 11

def pubdate
  @pubdate
end

Instance Method Details

#add_creator(name, role) ⇒ Object



65
66
67
68
69
70
# File 'lib/rb_latex/meta_info.rb', line 65

def add_creator(name, role)
  if !@creator[role]
    !@creator[role] = Array.new
  end
  @creator[role] << name
end

#allObject



42
43
44
# File 'lib/rb_latex/meta_info.rb', line 42

def all
##      @info
end

#author(sep = ", ") ⇒ Object



72
73
74
75
76
77
78
79
# File 'lib/rb_latex/meta_info.rb', line 72

def author(sep = ", ")
  aut = @creator["aut"]
  if aut
    aut.join(sep)
  else
    ""
  end
end

#date_format(time) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/rb_latex/meta_info.rb', line 57

def date_format(time)
  if time
    time.strftime("%Y年%-m月%-d日")
  else
    ""
  end
end

#lastmodified_to_sObject



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

def lastmodified_to_s
  date_format(@lastmodified)
end

#pubdate_to_sObject



26
27
28
# File 'lib/rb_latex/meta_info.rb', line 26

def pubdate_to_s
  date_format(@pubdate)
end

#to_latexObject



46
47
48
49
50
51
52
53
54
55
# File 'lib/rb_latex/meta_info.rb', line 46

def to_latex
  "\\title{#{escape_latex(title)}}\n"+
  "\\author{#{escape_latex(author)}}\n"+
  "\\date{}\n"+
  "\\newcommand{\\rblatexTitle}{#{escape_latex(title)}}\n"+
  "\\newcommand{\\rblatexAuthor}{#{escape_latex(author)}}\n"+
  "\\newcommand{\\rblatexPubdate}{#{escape_latex(pubdate_to_s)}}\n"+
  "\\newcommand{\\rblatexPublisher}{#{escape_latex(publisher)}}\n"+
  "\\newcommand{\\rblatexPageDirection}{#{escape_latex(page_progression_direction)}}\n"
end