Class: HParser::Inline::HatenaId
- Inherits:
-
Object
- Object
- HParser::Inline::HatenaId
- Includes:
- Collectable
- Defined in:
- lib/hparser/inline/hatena_id.rb,
lib/hparser/html.rb,
lib/hparser/text.rb,
lib/hparser/latex.rb,
lib/hparser/hatena.rb
Overview
hatena id parser.
For example:
id:mzp
Instance Attribute Summary collapse
-
#is_detail ⇒ Object
readonly
Returns the value of attribute is_detail.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #==(o) ⇒ Object
-
#initialize(name, is_detail = false) ⇒ HatenaId
constructor
A new instance of HatenaId.
- #to_hatena ⇒ Object
- #to_html ⇒ Object
- #to_latex ⇒ Object
- #to_text ⇒ Object
Constructor Details
#initialize(name, is_detail = false) ⇒ HatenaId
Returns a new instance of HatenaId.
15 16 17 18 |
# File 'lib/hparser/inline/hatena_id.rb', line 15 def initialize(name, is_detail=false) @name = name @is_detail = is_detail end |
Instance Attribute Details
#is_detail ⇒ Object (readonly)
Returns the value of attribute is_detail.
14 15 16 |
# File 'lib/hparser/inline/hatena_id.rb', line 14 def is_detail @is_detail end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/hparser/inline/hatena_id.rb', line 14 def name @name end |
Class Method Details
Instance Method Details
#==(o) ⇒ Object
26 27 28 |
# File 'lib/hparser/inline/hatena_id.rb', line 26 def ==(o) self.class == o.class and @name == o.name and @is_detail == o.is_detail end |
#to_hatena ⇒ Object
133 134 135 |
# File 'lib/hparser/hatena.rb', line 133 def to_hatena "id:#{self.name}" end |
#to_html ⇒ Object
306 307 308 309 310 311 312 313 314 |
# File 'lib/hparser/html.rb', line 306 def to_html if self.is_detail %(<a href="http://d.hatena.ne.jp/#{self.name}/" class="hatena-id-icon">) + %(<img src="http://www.st-hatena.com/users/#{self.name[0..1]}/#{self.name}/profile_s.gif") + %( width="16" height="16" alt="id:#{self.name}" class="hatena-id-icon">id:#{self.name}</a>) else %(<a href="http://d.hatena.ne.jp/#{self.name}/">id:#{self.name}</a>) end end |
#to_latex ⇒ Object
242 243 244 |
# File 'lib/hparser/latex.rb', line 242 def to_latex "\\href{http://d.hatena.ne.jp/#{self.name}/}{id:#{self.name}}" end |
#to_text ⇒ Object
154 155 156 |
# File 'lib/hparser/text.rb', line 154 def to_text "id:#{self.name}" end |