Class: YTag::Tag
- Inherits:
-
Object
- Object
- YTag::Tag
- Defined in:
- lib/ytag/tag.rb
Constant Summary collapse
- MARKUP =
{}
- BOGUS =
'system:undefined'
Instance Attribute Summary collapse
-
#active ⇒ Object
readonly
Returns the value of attribute active.
-
#hidden ⇒ Object
readonly
Returns the value of attribute hidden.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #access ⇒ Object
- #create ⇒ Object
-
#initialize(name, user, active = true, hidden = false) ⇒ Tag
constructor
A new instance of Tag.
- #modify ⇒ Object
- #print(stream = STDOUT) ⇒ Object
Constructor Details
#initialize(name, user, active = true, hidden = false) ⇒ Tag
Returns a new instance of Tag.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ytag/tag.rb', line 18 def initialize(name, user, active=true, hidden=false) raise ArgumentError, 'nil name' if name.nil? raise ArgumentError, 'invalid name class' if name.class != String raise ArgumentError, 'empty name' if name.empty? raise ArgumentError, 'nil user' if user.nil? raise ArgumentError, 'invalid user class' if user.class != String raise ArgumentError, 'empty user' if user.empty? raise ArgumentError, 'invalid active class' if \ active.class != TrueClass && active.class != FalseClass raise ArgumentError, 'invalid hidden class' if \ hidden.class != TrueClass && hidden.class != FalseClass @name = YTag::tagify(name) @user = user @active = active @hidden = hidden @timestamp = RCL::Timestamp.new nil end |
Instance Attribute Details
#active ⇒ Object (readonly)
Returns the value of attribute active.
13 14 15 |
# File 'lib/ytag/tag.rb', line 13 def active @active end |
#hidden ⇒ Object (readonly)
Returns the value of attribute hidden.
13 14 15 |
# File 'lib/ytag/tag.rb', line 13 def hidden @hidden end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/ytag/tag.rb', line 13 def name @name end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
13 14 15 |
# File 'lib/ytag/tag.rb', line 13 def user @user end |
Instance Method Details
#access ⇒ Object
47 48 49 |
# File 'lib/ytag/tag.rb', line 47 def access @timestamp.access end |
#create ⇒ Object
39 40 41 |
# File 'lib/ytag/tag.rb', line 39 def create @timestamp.create end |
#modify ⇒ Object
43 44 45 |
# File 'lib/ytag/tag.rb', line 43 def modify @timestamp.modify end |
#print(stream = STDOUT) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/ytag/tag.rb', line 51 def print(stream=STDOUT) raise 'nil stream' if stream.nil? raise 'invalid stream class' if stream.class != IO @timestamp.update_access stream << "#{@name} [" stream << 'in' if !@active stream << 'active, ' if !@hidden stream << 'public' else stream << 'private' end stream << "]\n" stream << "+ added by #{@user} on #{@timestamp.create}\n" stream << "+ last accessed on #{@timestamp.access}\n" nil end |