Class: PublishingPlatformPublishingComponents::ComponentDoc
- Inherits:
-
Object
- Object
- PublishingPlatformPublishingComponents::ComponentDoc
- Defined in:
- app/models/publishing_platform_publishing_components/component_doc.rb
Instance Attribute Summary collapse
-
#accessibility_excluded_rules ⇒ Object
readonly
Returns the value of attribute accessibility_excluded_rules.
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#component ⇒ Object
readonly
Returns the value of attribute component.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#embed ⇒ Object
readonly
Returns the value of attribute embed.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #accessibility_criteria ⇒ Object
- #display_html? ⇒ Boolean
- #display_preview? ⇒ Boolean
- #example ⇒ Object
- #examples ⇒ Object
- #github_search_url ⇒ Object
- #html_accessibility_criteria ⇒ Object
- #html_body ⇒ Object
-
#initialize(component) ⇒ ComponentDoc
constructor
A new instance of ComponentDoc.
- #other_examples ⇒ Object
- #partial_path ⇒ Object
- #publishing_platform_frontend_components ⇒ Object
Constructor Details
#initialize(component) ⇒ ComponentDoc
Returns a new instance of ComponentDoc.
12 13 14 15 16 17 18 19 20 21 |
# File 'app/models/publishing_platform_publishing_components/component_doc.rb', line 12 def initialize(component) @component = component @id = component[:id] @name = component[:name] @description = component[:description] @body = component[:body] @accessibility_excluded_rules = component[:accessibility_excluded_rules] @source = component[:source] @embed = component[:embed] end |
Instance Attribute Details
#accessibility_excluded_rules ⇒ Object (readonly)
Returns the value of attribute accessibility_excluded_rules.
3 4 5 |
# File 'app/models/publishing_platform_publishing_components/component_doc.rb', line 3 def accessibility_excluded_rules @accessibility_excluded_rules end |
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'app/models/publishing_platform_publishing_components/component_doc.rb', line 3 def body @body end |
#component ⇒ Object (readonly)
Returns the value of attribute component.
3 4 5 |
# File 'app/models/publishing_platform_publishing_components/component_doc.rb', line 3 def component @component end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'app/models/publishing_platform_publishing_components/component_doc.rb', line 3 def description @description end |
#embed ⇒ Object (readonly)
Returns the value of attribute embed.
3 4 5 |
# File 'app/models/publishing_platform_publishing_components/component_doc.rb', line 3 def @embed end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'app/models/publishing_platform_publishing_components/component_doc.rb', line 3 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'app/models/publishing_platform_publishing_components/component_doc.rb', line 3 def name @name end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
3 4 5 |
# File 'app/models/publishing_platform_publishing_components/component_doc.rb', line 3 def source @source end |
Instance Method Details
#accessibility_criteria ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/models/publishing_platform_publishing_components/component_doc.rb', line 23 def accessibility_criteria shared_accessibility_criteria = [] if component[:shared_accessibility_criteria].present? component[:shared_accessibility_criteria].each do |criteria| shared_accessibility_criteria << SharedAccessibilityCriteria.send(criteria) if SharedAccessibilityCriteria.respond_to? criteria end end "#{component[:accessibility_criteria]}\n#{shared_accessibility_criteria.join("\n")}" end |
#display_html? ⇒ Boolean
43 44 45 |
# File 'app/models/publishing_platform_publishing_components/component_doc.rb', line 43 def display_html? component[:display_html] end |
#display_preview? ⇒ Boolean
47 48 49 |
# File 'app/models/publishing_platform_publishing_components/component_doc.rb', line 47 def display_preview? component[:display_preview].nil? || component[:display_preview] end |
#example ⇒ Object
35 36 37 |
# File 'app/models/publishing_platform_publishing_components/component_doc.rb', line 35 def example examples.first end |
#examples ⇒ Object
76 77 78 79 80 81 82 |
# File 'app/models/publishing_platform_publishing_components/component_doc.rb', line 76 def examples @examples ||= component[:examples].map do |id, example_data| example_data ||= {} example_data["embed"] ||= ComponentExample.new(id.to_s, example_data) end end |
#github_search_url ⇒ Object
71 72 73 74 |
# File 'app/models/publishing_platform_publishing_components/component_doc.rb', line 71 def github_search_url params = { q: "org:publishing-platform components/components/#{id}", type: "Code" } "https://github.com/search?#{params.to_query}" end |
#html_accessibility_criteria ⇒ Object
55 56 57 |
# File 'app/models/publishing_platform_publishing_components/component_doc.rb', line 55 def html_accessibility_criteria markdown_to_html(accessibility_criteria) if accessibility_criteria.present? end |
#html_body ⇒ Object
51 52 53 |
# File 'app/models/publishing_platform_publishing_components/component_doc.rb', line 51 def html_body markdown_to_html(body) if body.present? end |
#other_examples ⇒ Object
39 40 41 |
# File 'app/models/publishing_platform_publishing_components/component_doc.rb', line 39 def other_examples examples.slice(1..-1) end |
#partial_path ⇒ Object
59 60 61 62 63 64 65 |
# File 'app/models/publishing_platform_publishing_components/component_doc.rb', line 59 def partial_path if source == "gem" "publishing_platform_publishing_components/components/#{id}" else "#{PublishingPlatformPublishingComponents::Config.component_directory_name}/#{id}" end end |
#publishing_platform_frontend_components ⇒ Object
67 68 69 |
# File 'app/models/publishing_platform_publishing_components/component_doc.rb', line 67 def publishing_platform_frontend_components component[:publishing_platform_frontend_components].to_a end |