Class: CMSBinding::Article

Inherits:
Base
  • Object
show all
Defined in:
lib/twm-cms-bindings.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#get_text

Constructor Details

#initialize(article, source, partial) ⇒ Article

Returns a new instance of Article.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/twm-cms-bindings.rb', line 84

def initialize (article, source, partial)
  @source = source
  @attachments = []
  @fields = {}
  @partial = partial
  
  @id = article.attributes['id'].to_str
  @headline = get_text( REXML::XPath.first( article, "headline" ) )

  if( partial == false ) 
    @categoryID = REXML::XPath.first( article, "category" ).attributes['id'].to_str
    @small_intro = get_text( REXML::XPath.first( article, "smallintro" ) )
    @large_intro = get_text( REXML::XPath.first( article, "largeintro" ) )
    @contents = get_text( REXML::XPath.first( article, "body" ) )
    @keywords = get_text( REXML::XPath.first( article, "keywords" ) ).split(',')
    @date = get_text( REXML::XPath.first( article, "date" ) )
    
    REXML::XPath.each( article, "field") {|field|
      key = field.attributes['name'].to_s
      value = get_text( REXML::XPath.first( field, "."))
      @fields[key.strip] = value.strip
    }
    REXML::XPath.each( article, "attachments/attachment" ) {|attachment|
      @attachments << CMSBinding::ArticleAttachment.new(attachment, @source)
    }
  end
end

Instance Attribute Details

#attachmentsObject (readonly)

Returns the value of attribute attachments.



81
82
83
# File 'lib/twm-cms-bindings.rb', line 81

def attachments
  @attachments
end

#categoryIDObject (readonly)

Returns the value of attribute categoryID.



81
82
83
# File 'lib/twm-cms-bindings.rb', line 81

def categoryID
  @categoryID
end

#contentsObject (readonly)

Returns the value of attribute contents.



81
82
83
# File 'lib/twm-cms-bindings.rb', line 81

def contents
  @contents
end

#dateObject (readonly)

Returns the value of attribute date.



81
82
83
# File 'lib/twm-cms-bindings.rb', line 81

def date
  @date
end

#fieldsObject (readonly)

Returns the value of attribute fields.



81
82
83
# File 'lib/twm-cms-bindings.rb', line 81

def fields
  @fields
end

#headlineObject (readonly)

Returns the value of attribute headline.



81
82
83
# File 'lib/twm-cms-bindings.rb', line 81

def headline
  @headline
end

#idObject (readonly)

Returns the value of attribute id.



81
82
83
# File 'lib/twm-cms-bindings.rb', line 81

def id
  @id
end

#keywordsObject (readonly)

Returns the value of attribute keywords.



81
82
83
# File 'lib/twm-cms-bindings.rb', line 81

def keywords
  @keywords
end

#large_introObject (readonly)

Returns the value of attribute large_intro.



81
82
83
# File 'lib/twm-cms-bindings.rb', line 81

def large_intro
  @large_intro
end

#small_introObject (readonly)

Returns the value of attribute small_intro.



81
82
83
# File 'lib/twm-cms-bindings.rb', line 81

def small_intro
  @small_intro
end