Class: TaggedContent::TagExtractor
- Inherits:
-
Object
- Object
- TaggedContent::TagExtractor
- Defined in:
- lib/docfolio/paragraph_modules/tags.rb
Class Attribute Summary collapse
-
.section ⇒ Object
Returns the value of attribute section.
Instance Attribute Summary collapse
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Class Method Summary collapse
- .all_tags ⇒ Object
-
.reset ⇒ Object
resets the class variables so that a new file can be parsed is called by LearningDiary (through Paragraph) when preparing to parse a new txt file.
Instance Method Summary collapse
-
#content(tag, str = '') ⇒ Object
Joins all content in @tags of with a tag of type tag.
-
#creditable? ⇒ Boolean
true if the paragraph contains a tag that can earn credit.
- #extract_content(rest_of_str) ⇒ Object
-
#impact_creditable? ⇒ Boolean
true if the paragraph contains a tag that can earn impact credit.
-
#initialize ⇒ TagExtractor
constructor
A new instance of TagExtractor.
-
#significant_event? ⇒ Boolean
true if the paragraph contains a tag used in significant events i.e.
-
#tag?(tag) ⇒ Boolean
returns true if any tags are of type tag.
Constructor Details
#initialize ⇒ TagExtractor
Returns a new instance of TagExtractor.
8 9 10 |
# File 'lib/docfolio/paragraph_modules/tags.rb', line 8 def initialize @tags = [] end |
Class Attribute Details
.section ⇒ Object
Returns the value of attribute section.
16 17 18 |
# File 'lib/docfolio/paragraph_modules/tags.rb', line 16 def section @section end |
Instance Attribute Details
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
6 7 8 |
# File 'lib/docfolio/paragraph_modules/tags.rb', line 6 def @tags end |
Class Method Details
.all_tags ⇒ Object
26 27 28 |
# File 'lib/docfolio/paragraph_modules/tags.rb', line 26 def self. SECTIONS + TAGS end |
.reset ⇒ Object
resets the class variables so that a new file can be parsed is called by LearningDiary (through Paragraph) when preparing to parse a new txt file
22 23 24 |
# File 'lib/docfolio/paragraph_modules/tags.rb', line 22 def self.reset TagExtractor.section = 0 # :TITLE end |
Instance Method Details
#content(tag, str = '') ⇒ Object
Joins all content in @tags of with a tag of type tag
59 60 61 62 63 64 |
# File 'lib/docfolio/paragraph_modules/tags.rb', line 59 def content(tag, str = '') tag_index = 0 content_index = 1 @tags.each { |t| str << t[content_index] + ' ' if t[tag_index] == tag } str end |
#creditable? ⇒ Boolean
true if the paragraph contains a tag that can earn credit
67 68 69 70 |
# File 'lib/docfolio/paragraph_modules/tags.rb', line 67 def creditable? .each { |t| return true if CREDITABLE.include?(t[0]) } false end |
#extract_content(rest_of_str) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/docfolio/paragraph_modules/tags.rb', line 30 def extract_content(rest_of_str) # if a new date or time has not been found then return return if rest_of_str == '' @old_tags = @tags @tags += (rest_of_str) if # As soon as tags are extracted, there can only be note internal # paragraph sections TagExtractor.section = 2 #:NOTE else # No tags have been extracted from the str, so use the paragraphs # current section tag_as_section(rest_of_str) end end |
#impact_creditable? ⇒ Boolean
true if the paragraph contains a tag that can earn impact credit
80 81 82 83 |
# File 'lib/docfolio/paragraph_modules/tags.rb', line 80 def impact_creditable? .each { |t| return true if t[0] == :I } false end |
#significant_event? ⇒ Boolean
true if the paragraph contains a tag used in significant events i.e. is the learning diary a significant event?
74 75 76 77 |
# File 'lib/docfolio/paragraph_modules/tags.rb', line 74 def significant_event? .each { |t| return true if SIG_EVENT.include?(t[0]) } false end |
#tag?(tag) ⇒ Boolean
returns true if any tags are of type tag
50 51 52 53 |
# File 'lib/docfolio/paragraph_modules/tags.rb', line 50 def tag?(tag) @tags.each { |t| return true if t[0] == tag } false end |